Update contrib.
2 * Copyright (c) 2006-2009 Nokia Corporation and/or its subsidiary(-ies).
4 * This component and the accompanying materials are made available
5 * under the terms of the License "Eclipse Public License v1.0"
6 * which accompanies this distribution, and is available
7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
9 * Initial Contributors:
10 * Nokia Corporation - initial contribution.
15 * RSA shim classes definition
29 #include <asymmetric.h>
33 class CAsymmetricCipher;
39 NONSHARABLE_CLASS(CRSAPKCS1v15EncryptorShim) : public CRSAPKCS1v15Encryptor
43 Creates an RSAPKCS1v15EncryptorShim object which has the same interface
44 as CRSAPKCS1v15Encryptor but delegates all work to a Crypto SPI plug-in.
46 @param aKey The encryption key
47 @return A pointer to a CRSAPKCS1v15EncryptorShim instance
49 static CRSAPKCS1v15EncryptorShim* NewL(const CRSAPublicKey& aKey);
52 Creates an RSAPKCS1v15EncryptorShim object which has the same interface
53 as CRSAPKCS1v15Encryptor but delegates all work to a Crypto SPI plug-in.
55 A pointer to the new object is placed on the cleanup stack
57 @param aKey The encryption key
58 @return A pointer to a CRSAPKCS1v15EncryptorShim instance
60 static CRSAPKCS1v15EncryptorShim* NewLC(const CRSAPublicKey& aKey);
62 // From CRSAPKCS1v15Encryptor
63 void EncryptL(const TDesC8& aInput, TDes8& aOutput) const;
64 TInt MaxInputLength(void) const;
65 TInt MaxOutputLength(void) const;
68 ~CRSAPKCS1v15EncryptorShim();
72 CRSAPKCS1v15EncryptorShim(const CRSAPublicKey& aKey);
73 void ConstructL(const CRSAPublicKey& aKey);
77 CryptoSpi::CAsymmetricCipher* iAsymmetricCipherImpl;
79 /// SPI requires all key to passed as key-objects
80 CryptoSpi::CKey* iKey;
83 NONSHARABLE_CLASS(CRSAPKCS1v15DecryptorShim) : public CRSAPKCS1v15Decryptor
87 Creates an RSAPKCS1v15DecryptorShim object which has the same interface
88 as CRSAPKCS1v15Decryptor but delegates all work to a Crypto SPI plug-in.
90 @param aKey The decryption key
91 @return A pointer to a CRSAPKCS1v15DecryptorShim instance
93 static CRSAPKCS1v15DecryptorShim* NewL(const CRSAPrivateKey& aKey);
96 Creates an RSAPKCS1v15EncryptorShim object which has the same interface
97 as CRSAPKCS1v15Decryptor but delegates all work to a Crypto SPI plug-in.
99 A pointer to the new object is placed on the cleanup stack
101 @param aKey The decryption key
102 @return A pointer to a CRSAPKCS1v15DecryptorShim instance
104 static CRSAPKCS1v15DecryptorShim* NewLC(const CRSAPrivateKey& aKey);
106 // From CRSAPKCS1v15Decryptor
107 void DecryptL(const TDesC8& aInput, TDes8& aOutput) const;
108 TInt MaxInputLength(void) const;
109 TInt MaxOutputLength(void) const;
112 ~CRSAPKCS1v15DecryptorShim();
116 CRSAPKCS1v15DecryptorShim(const CRSAPrivateKey& aKey);
117 void ConstructL(const CRSAPrivateKey& aKey);
121 CryptoSpi::CAsymmetricCipher* iAsymmetricCipherImpl;
123 /// SPI requires all key to passed as key-objects
124 CryptoSpi::CKey* iKey;
127 NONSHARABLE_CLASS(CRSAPKCS1v15SignerShim) : public CRSAPKCS1v15Signer
131 Creates a new CRSAPKCS1v15SignerShim object which has the same interface
132 as CRSAPKCS1v15Signer but delegates all work to a Crypto SPI plug-in.
134 @param aKey The RSA private key to be used for signing
135 @return A pointer to a CRSAPKCS1v15SignerShim instance
136 @leave KErrKeySize If the key length is too small
138 static CRSAPKCS1v15SignerShim* NewL(const CRSAPrivateKey& aKey);
141 Creates a new CRSAPKCS1v15SignerShim object which has the same interface
142 as CRSAPKCS1v15Signer but delegates all work to a Crypto SPI plug-in.
144 @param aKey The RSA private key to be used for signing
145 @return A pointer to a CRSAPKCS1v15SignerShim instance
146 @leave KErrKeySize If the key length is too small
148 static CRSAPKCS1v15SignerShim* NewLC(const CRSAPrivateKey& aKey);
150 // From CRSAPKCS1v15Signer
151 virtual CRSASignature* SignL(const TDesC8& aInput) const;
152 virtual TInt MaxInputLength(void) const;
153 virtual TInt MaxOutputLength(void) const;
154 /** The destructor frees all resources owned by the object, prior to its destruction.*/
155 ~CRSAPKCS1v15SignerShim(void);
158 CRSAPKCS1v15SignerShim(const CRSAPrivateKey& aKey);
159 void ConstructL(const CRSAPrivateKey& aKey);
163 CryptoSpi::CSigner* iSignerImpl;
165 /// SPI requires all key to passed as key-objects
166 CryptoSpi::CKey* iKey;
168 CRSAPKCS1v15SignerShim(const CRSAPKCS1v15SignerShim&);
169 CRSAPKCS1v15SignerShim& operator=(const CRSAPKCS1v15SignerShim&);
173 * This class verifies RSA signatures given a message and its supposed
174 * signature. It follows the RSA PKCS#1 v1.5 with PKCS#1 v1.5 padding specification
175 * with the following exception: the VerifyL() function does <b>not</b> hash or
176 * in any way manipulate the input data before checking. Thus in order to verify
177 * RSA signatures in PKCS#1 v1.5 format, the input data needs to follow PKCS#1 v1.5
178 * specification, i.e. be ASN.1 encoded and prefixed by ASN.1 encoded digestId.
183 NONSHARABLE_CLASS(CRSAPKCS1v15VerifierShim) : public CRSAPKCS1v15Verifier
189 Creates a new CRSAPKCS1v15VerifierShim object which has the same interface
190 as CRSAPKCS1v15Verifier but delegates all work to a Crypto SPI plug-in.
192 @param aKey The RSA public key to be used for verifying
193 @return A pointer to a CRSAPKCS1v15VerifierShim instance
194 @leave KErrKeySize If the key length is too small
196 static CRSAPKCS1v15VerifierShim* NewL(const CRSAPublicKey& aKey);
201 Creates a new CRSAPKCS1v15VerifierShim object which has the same interface
202 as CRSAPKCS1v15Verifier but delegates all work to a Crypto SPI plug-in.
204 The returned pointer is put onto the cleanup stack.
206 @param aKey The RSA public key to be used for verifying
207 @return A pointer to a CRSAPKCS1v15VerifierShim instance
209 @leave KErrKeySize If the key length is too small
211 static CRSAPKCS1v15VerifierShim* NewLC(const CRSAPublicKey& aKey);
213 // CRSAPKCS1v15Verifier
214 virtual TInt MaxInputLength(void) const;
215 virtual TInt MaxOutputLength(void) const;
218 virtual TBool VerifyL(const TDesC8& aInput, const CRSASignature& aSignature) const;
219 virtual HBufC8* InverseSignLC(const CRSASignature& aSignature) const;
221 /** The destructor frees all resources owned by the object, prior to its destruction. */
222 virtual ~CRSAPKCS1v15VerifierShim(void);
224 CRSAPKCS1v15VerifierShim(const CRSAPublicKey& aKey);
225 void ConstructL(const CRSAPublicKey& aKey);
229 CryptoSpi::CVerifier* iVerifierImpl;
231 /// SPI requires all key to passed as key-objects
232 CryptoSpi::CKey* iKey;
234 CRSAPKCS1v15VerifierShim(const CRSAPKCS1v15VerifierShim&);
235 CRSAPKCS1v15VerifierShim& operator=(const CRSAPKCS1v15VerifierShim&);
238 #endif // __RSASHIM_H__