equal
deleted
inserted
replaced
10 * Nokia Corporation - initial contribution. |
10 * Nokia Corporation - initial contribution. |
11 * |
11 * |
12 * Contributors: |
12 * Contributors: |
13 * |
13 * |
14 * Description: |
14 * Description: |
15 * ** IMPORTANT ** PublishedPartner API's in this file are published to 3rd party developers via the |
15 * ** IMPORTANT ** API's in this file are published to 3rd party developers via the |
16 * Symbian website. Changes to these API's should be treated as PublishedAll API changes and the Security TA should be consulted. |
16 * Symbian website. Changes to these API's should be treated as PublishedAll API changes and the Security TA should be consulted. |
17 * Asymmetric crypto implementation |
17 * Asymmetric crypto implementation |
18 * |
18 * |
19 */ |
19 */ |
20 |
20 |
21 |
21 |
22 |
|
23 |
|
24 /** |
22 /** |
25 @file |
23 @file |
26 @internalAll |
24 @publishedAll |
|
25 @released |
27 */ |
26 */ |
28 |
27 |
29 #ifndef __ASYMMETRIC_H__ |
28 #ifndef __ASYMMETRIC_H__ |
30 #define __ASYMMETRIC_H__ |
29 #define __ASYMMETRIC_H__ |
31 |
30 |
40 |
39 |
41 /** |
40 /** |
42 * Mixin class defining common operations for public key encryption and |
41 * Mixin class defining common operations for public key encryption and |
43 * decryption classes. |
42 * decryption classes. |
44 * |
43 * |
45 * @publishedPartner |
|
46 * @released |
|
47 */ |
44 */ |
48 class MCryptoSystem |
45 class MCryptoSystem |
49 { |
46 { |
50 public: |
47 public: |
51 /** |
48 /** |
72 }; |
69 }; |
73 |
70 |
74 /** |
71 /** |
75 * Abstract base class for all public key encryptors. |
72 * Abstract base class for all public key encryptors. |
76 * |
73 * |
77 * @publishedPartner |
|
78 * @released |
|
79 */ |
74 */ |
80 class CEncryptor : public CBase, public MCryptoSystem |
75 class CEncryptor : public CBase, public MCryptoSystem |
81 { |
76 { |
82 public: |
77 public: |
83 /** |
78 /** |
101 }; |
96 }; |
102 |
97 |
103 /** |
98 /** |
104 * Abstract base class for all public key decryptors. |
99 * Abstract base class for all public key decryptors. |
105 * |
100 * |
106 * @publishedPartner |
|
107 * @released |
|
108 */ |
101 */ |
109 class CDecryptor : public CBase, public MCryptoSystem |
102 class CDecryptor : public CBase, public MCryptoSystem |
110 { |
103 { |
111 public: |
104 public: |
112 /** |
105 /** |
130 }; |
123 }; |
131 |
124 |
132 /** |
125 /** |
133 * Implementation of RSA encryption as described in PKCS#1 v1.5. |
126 * Implementation of RSA encryption as described in PKCS#1 v1.5. |
134 * |
127 * |
135 * @publishedPartner |
|
136 * @released |
|
137 */ |
128 */ |
138 class CRSAPKCS1v15Encryptor : public CEncryptor |
129 class CRSAPKCS1v15Encryptor : public CEncryptor |
139 { |
130 { |
140 public: |
131 public: |
141 /** |
132 /** |
186 }; |
177 }; |
187 |
178 |
188 /** |
179 /** |
189 * Implementation of RSA decryption as described in PKCS#1 v1.5. |
180 * Implementation of RSA decryption as described in PKCS#1 v1.5. |
190 * |
181 * |
191 * @publishedPartner |
|
192 * @released |
|
193 */ |
182 */ |
194 class CRSAPKCS1v15Decryptor : public CDecryptor |
183 class CRSAPKCS1v15Decryptor : public CDecryptor |
195 { |
184 { |
196 public: |
185 public: |
197 /** |
186 /** |
241 }; |
230 }; |
242 |
231 |
243 /** |
232 /** |
244 * Mixin class defining operations common to all public key signature systems. |
233 * Mixin class defining operations common to all public key signature systems. |
245 * |
234 * |
246 * @publishedPartner |
|
247 * @released |
|
248 */ |
235 */ |
249 class MSignatureSystem |
236 class MSignatureSystem |
250 { |
237 { |
251 public: |
238 public: |
252 /** |
239 /** |
269 * The template parameter, CSignature, should be a class that encapsulates the |
256 * The template parameter, CSignature, should be a class that encapsulates the |
270 * concept of a digital signature. Derived signature classes must own their |
257 * concept of a digital signature. Derived signature classes must own their |
271 * respective signatures (and hence be CBase derived). There are no other |
258 * respective signatures (and hence be CBase derived). There are no other |
272 * restrictions on the formation of the signature classes. |
259 * restrictions on the formation of the signature classes. |
273 * |
260 * |
274 * @publishedPartner |
|
275 * @released |
|
276 */ |
261 */ |
277 template <class CSignature> class CSigner : public CBase, public MSignatureSystem |
262 template <class CSignature> class CSigner : public CBase, public MSignatureSystem |
278 { |
263 { |
279 public: |
264 public: |
280 /** |
265 /** |
303 * The template parameter, CSignature, should be a class that encapsulates the |
288 * The template parameter, CSignature, should be a class that encapsulates the |
304 * concept of a digital signature. Derived signature classes must own their |
289 * concept of a digital signature. Derived signature classes must own their |
305 * respective signatures (and hence be CBase derived). There are no other |
290 * respective signatures (and hence be CBase derived). There are no other |
306 * restrictions on the formation of the signature classes. |
291 * restrictions on the formation of the signature classes. |
307 * |
292 * |
308 * @publishedPartner |
|
309 * @released |
|
310 */ |
293 */ |
311 template <class CSignature> class CVerifier : public CBase, public MSignatureSystem |
294 template <class CSignature> class CVerifier : public CBase, public MSignatureSystem |
312 { |
295 { |
313 public: |
296 public: |
314 /** |
297 /** |
335 #include <asymmetric.inl> |
318 #include <asymmetric.inl> |
336 |
319 |
337 /** |
320 /** |
338 * An encapsulation of a RSA signature. |
321 * An encapsulation of a RSA signature. |
339 * |
322 * |
340 * @publishedPartner |
|
341 * @released |
|
342 */ |
323 */ |
343 class CRSASignature : public CBase |
324 class CRSASignature : public CBase |
344 { |
325 { |
345 public: |
326 public: |
346 /** |
327 /** |
402 }; |
383 }; |
403 |
384 |
404 /** |
385 /** |
405 * Abstract base class for all RSA Signers. |
386 * Abstract base class for all RSA Signers. |
406 * |
387 * |
407 * @publishedPartner |
|
408 * @released |
|
409 */ |
388 */ |
410 class CRSASigner : public CSigner<CRSASignature> |
389 class CRSASigner : public CSigner<CRSASignature> |
411 { |
390 { |
412 public: |
391 public: |
413 /** |
392 /** |
431 * the one caveat noted below) and using PKCS#1 v1.5 signature padding. The only |
410 * the one caveat noted below) and using PKCS#1 v1.5 signature padding. The only |
432 * exception is that the SignL() function simply performs a 'raw' PKCS#1 v1.5 sign |
411 * exception is that the SignL() function simply performs a 'raw' PKCS#1 v1.5 sign |
433 * operation on whatever it is given. It does <b>not</b> hash or in any way |
412 * operation on whatever it is given. It does <b>not</b> hash or in any way |
434 * manipulate the input data before signing. |
413 * manipulate the input data before signing. |
435 * |
414 * |
436 * @publishedPartner |
|
437 * @released |
|
438 */ |
415 */ |
439 class CRSAPKCS1v15Signer : public CRSASigner |
416 class CRSAPKCS1v15Signer : public CRSASigner |
440 { |
417 { |
441 public: |
418 public: |
442 /** |
419 /** |
493 }; |
470 }; |
494 |
471 |
495 /** |
472 /** |
496 * Abstract base class for all RSA Verifiers. |
473 * Abstract base class for all RSA Verifiers. |
497 * |
474 * |
498 * @publishedPartner |
|
499 * @released |
|
500 */ |
475 */ |
501 class CRSAVerifier : public CVerifier<CRSASignature> |
476 class CRSAVerifier : public CVerifier<CRSASignature> |
502 { |
477 { |
503 public: |
478 public: |
504 /** |
479 /** |
538 * with the following exception: the VerifyL() function does <b>not</b> hash or |
513 * with the following exception: the VerifyL() function does <b>not</b> hash or |
539 * in any way manipulate the input data before checking. Thus in order to verify |
514 * in any way manipulate the input data before checking. Thus in order to verify |
540 * RSA signatures in PKCS#1 v1.5 format, the input data needs to follow PKCS#1 v1.5 |
515 * RSA signatures in PKCS#1 v1.5 format, the input data needs to follow PKCS#1 v1.5 |
541 * specification, i.e. be ASN.1 encoded and prefixed by ASN.1 encoded digestId. |
516 * specification, i.e. be ASN.1 encoded and prefixed by ASN.1 encoded digestId. |
542 * |
517 * |
543 * @publishedPartner |
|
544 * @released |
|
545 */ |
518 */ |
546 class CRSAPKCS1v15Verifier : public CRSAVerifier |
519 class CRSAPKCS1v15Verifier : public CRSAVerifier |
547 { |
520 { |
548 public: |
521 public: |
549 /** |
522 /** |
588 }; |
561 }; |
589 |
562 |
590 /** |
563 /** |
591 * An encapsulation of a DSA signature. |
564 * An encapsulation of a DSA signature. |
592 * |
565 * |
593 * @publishedPartner |
|
594 * @released |
|
595 */ |
566 */ |
596 class CDSASignature : public CBase |
567 class CDSASignature : public CBase |
597 { |
568 { |
598 public: |
569 public: |
599 /** |
570 /** |
662 }; |
633 }; |
663 |
634 |
664 /** |
635 /** |
665 * Implementation of DSA signing as specified in FIPS 186-2 change request 1. |
636 * Implementation of DSA signing as specified in FIPS 186-2 change request 1. |
666 * |
637 * |
667 * @publishedPartner |
|
668 * @released |
|
669 */ |
638 */ |
670 class CDSASigner : public CSigner<CDSASignature> |
639 class CDSASigner : public CSigner<CDSASignature> |
671 { |
640 { |
672 public: |
641 public: |
673 /** |
642 /** |
715 |
684 |
716 /** |
685 /** |
717 * Implementation of DSA signature verification as specified in FIPS 186-2 change |
686 * Implementation of DSA signature verification as specified in FIPS 186-2 change |
718 * request 1. |
687 * request 1. |
719 * |
688 * |
720 * @publishedPartner |
|
721 * @released |
|
722 */ |
689 */ |
723 class CDSAVerifier : public CVerifier<CDSASignature> |
690 class CDSAVerifier : public CVerifier<CDSASignature> |
724 { |
691 { |
725 public: |
692 public: |
726 /** |
693 /** |
766 }; |
733 }; |
767 |
734 |
768 /** |
735 /** |
769 * Implementation of Diffie-Hellman key agreement as specified in PKCS#3. |
736 * Implementation of Diffie-Hellman key agreement as specified in PKCS#3. |
770 * |
737 * |
771 * @publishedPartner |
|
772 * @released |
|
773 */ |
738 */ |
774 class CDH : public CBase |
739 class CDH : public CBase |
775 { |
740 { |
776 public: |
741 public: |
777 /** |
742 /** |