cryptoservices/certificateandkeymgmt/inc/x509keys.h
changeset 8 35751d3474b7
parent 0 2c201484c85f
equal deleted inserted replaced
2:675a964f4eb5 8:35751d3474b7
    15 * X.509 key classes and utility classes for key encoding/decoding.
    15 * X.509 key classes and utility classes for key encoding/decoding.
    16 *
    16 *
    17 */
    17 */
    18 
    18 
    19 
    19 
    20 
       
    21 
       
    22 /**
    20 /**
    23  @file
    21  @file
    24  @internalTechnology 
    22  @publishedAll
       
    23  @released
    25 */
    24 */
    26 
    25 
    27 #if !defined (__X509KEYS_H__)
    26 #if !defined (__X509KEYS_H__)
    28 #define __X509KEYS_H__
    27 #define __X509KEYS_H__
    29 
    28 
    39 class CASN1EncBase;
    38 class CASN1EncBase;
    40 class CASN1EncContainer;
    39 class CASN1EncContainer;
    41 class CASN1EncSequence;
    40 class CASN1EncSequence;
    42 class CASN1EncBitString;
    41 class CASN1EncBitString;
    43 
    42 
       
    43 
       
    44 #ifndef SYMBIAN_ENABLE_SPLIT_HEADERS
       
    45 #include <x509keyencoder.h>
       
    46 #endif
       
    47 
    44 class CX509RSAPublicKey : public CRSAPublicKey
    48 class CX509RSAPublicKey : public CRSAPublicKey
    45 /** Adds the capability to decode DER-encoded RSA public keys.
    49 /** Adds the capability to decode DER-encoded RSA public keys.
    46 *
    50 *
    47 * Adds a commitment to a specific encoding scheme allowing X.509 RSA public key 
    51 * Adds a commitment to a specific encoding scheme allowing X.509 RSA public key 
    48 * superclasses to remain encoding-independent.
    52 * superclasses to remain encoding-independent.
    49 *
    53 *
    50 * @publishedAll
       
    51 * @released
       
    52 *
    54 *
    53 * @since v6.0 
    55 * @since v6.0 
    54 */
    56 */
    55 	{
    57 	{
    56 public:
    58 public:
    93 
    95 
    94 class TASN1EncRSAPublicKey
    96 class TASN1EncRSAPublicKey
    95 /**
    97 /**
    96  * Class for encoding RSA public keys to ASN.1 encoding.
    98  * Class for encoding RSA public keys to ASN.1 encoding.
    97  * 
    99  * 
    98  * @publishedAll
       
    99  * @released
       
   100  * @since v8.0 
   100  * @since v8.0 
   101  */
   101  */
   102 	{
   102 	{
   103 public:
   103 public:
   104 	/** 
   104 	/** 
   118 
   118 
   119 class TASN1DecRSAPublicKey
   119 class TASN1DecRSAPublicKey
   120 /** 
   120 /** 
   121  * Class for decoding RSA public keys from ASN.1 DER encoding.
   121  * Class for decoding RSA public keys from ASN.1 DER encoding.
   122  * 
   122  * 
   123  * @publishedAll
       
   124  * @released
       
   125  * @since v8.0
   123  * @since v8.0
   126  */
   124  */
   127 	{
   125 	{
   128 public:
   126 public:
   129 	/** 
   127 	/** 
   139 
   137 
   140 class TASN1DecRSAKeyPair
   138 class TASN1DecRSAKeyPair
   141 /** 
   139 /** 
   142  * Class for decoding RSA key pairs from ASN.1 DER encoding.
   140  * Class for decoding RSA key pairs from ASN.1 DER encoding.
   143  * 
   141  * 
   144  * @publishedAll
       
   145  * @released
       
   146  * @since v8.0
   142  * @since v8.0
   147  */
   143  */
   148 	{
   144 	{
   149 public:
   145 public:
   150 	/**
   146 	/**
   169 /** Encapsulates the X.509 DSA public key.
   165 /** Encapsulates the X.509 DSA public key.
   170 * 
   166 * 
   171 * Adds a commitment to a specific encoding scheme allowing superclasses to remain 
   167 * Adds a commitment to a specific encoding scheme allowing superclasses to remain 
   172 * encoding-independent. 
   168 * encoding-independent. 
   173 * 
   169 * 
   174 * @publishedAll
       
   175 * @released
       
   176 * @since v6.0 
   170 * @since v6.0 
   177 */
   171 */
   178 // DSA public key, params, signature.
   172 // DSA public key, params, signature.
   179 	{
   173 	{
   180 public:
   174 public:
   254  
   248  
   255 class TASN1DecDSAKeyPair
   249 class TASN1DecDSAKeyPair
   256 /** 
   250 /** 
   257  * Class for decoding DSA key pairs from ASN.1 DER encoding.
   251  * Class for decoding DSA key pairs from ASN.1 DER encoding.
   258  * 
   252  * 
   259  * @publishedAll
       
   260  * @released
       
   261  * @since v8.0
   253  * @since v8.0
   262  */
   254  */
   263 	{
   255 	{
   264 public:
   256 public:
   265 	/**
   257 	/**
   290 	};
   282 	};
   291 
   283 
   292 /**
   284 /**
   293  * Class for encoding DSA public keys to ASN.1 encoding.
   285  * Class for encoding DSA public keys to ASN.1 encoding.
   294  * 
   286  * 
   295  * @publishedAll
       
   296  * @released
       
   297  * @since v8.0
   287  * @since v8.0
   298  */
   288  */
   299 class TASN1EncDSAPublicKey
   289 class TASN1EncDSAPublicKey
   300 	{
   290 	{
   301 public:
   291 public:
   348 /** Encapsulates the X.509 DSA signature.
   338 /** Encapsulates the X.509 DSA signature.
   349 * 
   339 * 
   350 * Adds a commitment to a specific encoding scheme allowing superclasses to remain 
   340 * Adds a commitment to a specific encoding scheme allowing superclasses to remain 
   351 * encoding-independent. 
   341 * encoding-independent. 
   352 * 
   342 * 
   353 * @publishedAll
       
   354 * @released
       
   355 * @since v6.0 */
   343 * @since v6.0 */
   356 	{
   344 	{
   357 public:
   345 public:
   358 	/** Creates a new DSA Signature object from the specified buffer containing the 
   346 	/** Creates a new DSA Signature object from the specified buffer containing the 
   359 	* encoded binary representation.
   347 	* encoded binary representation.
   392 
   380 
   393 class CX509DHPublicKey : public CDHPublicKey
   381 class CX509DHPublicKey : public CDHPublicKey
   394 /** Provides clients with the information they need for Diffie-Hellman key exchange 
   382 /** Provides clients with the information they need for Diffie-Hellman key exchange 
   395 * within a protocol. 
   383 * within a protocol. 
   396 * 
   384 * 
   397 * @publishedAll
       
   398 * @released
       
   399 * @since v6.0 */
   385 * @since v6.0 */
   400 	{
   386 	{
   401 public:
   387 public:
   402 	/** Creates a new CX509DHPublicKey object from the specified buffer containing the encoded 
   388 	/** Creates a new CX509DHPublicKey object from the specified buffer containing the encoded 
   403 	* binary representation.
   389 	* binary representation.
   427 	};
   413 	};
   428 
   414 
   429 class CX509DHKeyPair : public CDHKeyPair
   415 class CX509DHKeyPair : public CDHKeyPair
   430 /** This class represents the Diffie-Hellman Key Pair.
   416 /** This class represents the Diffie-Hellman Key Pair.
   431 *
   417 *
   432 * @publishedAll
       
   433 * @released
       
   434 * @since v8.0 */
   418 * @since v8.0 */
   435 {
   419 {
   436 public:
   420 public:
   437 	/** Creates a new DH key pair object from the specified buffer containing 
   421 	/** Creates a new DH key pair object from the specified buffer containing 
   438 	* the encoded binary representation .
   422 	* the encoded binary representation .
   468 * 
   452 * 
   469 * Provides access to the DH Validation Parameters, which are used to determine 
   453 * Provides access to the DH Validation Parameters, which are used to determine 
   470 * if the DH Public Key has been generated in conformance with the algorithm 
   454 * if the DH Public Key has been generated in conformance with the algorithm 
   471 * specified in ESDH (see RFC 2631). 
   455 * specified in ESDH (see RFC 2631). 
   472 * 
   456 * 
   473 * @publishedAll
       
   474 * @released
       
   475 * @since v6.0 */
   457 * @since v6.0 */
   476 	{
   458 	{
   477 public:
   459 public:
   478 	/** Creates a new DH Validation parameters object from the specified buffer containing 
   460 	/** Creates a new DH Validation parameters object from the specified buffer containing 
   479 	* the encoded binary representation.
   461 	* the encoded binary representation.
   531 
   513 
   532 class CX509DHDomainParams : public CBase
   514 class CX509DHDomainParams : public CBase
   533 /** Encapsulates the compulsory Diffie-Hellman domain parameter values P and G 
   515 /** Encapsulates the compulsory Diffie-Hellman domain parameter values P and G 
   534 * (See RFC 2459). 
   516 * (See RFC 2459). 
   535 * 
   517 * 
   536 * @publishedAll
       
   537 * @released
       
   538 * @since v6.0 */
   518 * @since v6.0 */
   539 	{
   519 	{
   540 public:
   520 public:
   541 	/** Creates a new DH Domain parameters object from the specified buffer containing 
   521 	/** Creates a new DH Domain parameters object from the specified buffer containing 
   542 	* the encoded binary representation.
   522 	* the encoded binary representation.
   616 	RInteger iQ;
   596 	RInteger iQ;
   617 	RInteger iJ;
   597 	RInteger iJ;
   618 	CX509DHValidationParams* iValidationParams;
   598 	CX509DHValidationParams* iValidationParams;
   619 	};
   599 	};
   620 
   600 
   621 class TX509KeyEncoder
       
   622 /**
       
   623  * Abstract class that is the base class for RSA and DSA key encoder classes.
       
   624  * These classes are used to encode the X509 ASN.1 types AlgorithmIdentifier and
       
   625  * SubjectPublicKeyInfo.
       
   626  *
       
   627  * This class is part of the pkcs10 API, and will be changed or removed in a
       
   628  * future release.  You should not use it.
       
   629  * 
       
   630  * @internalTechnology 
       
   631  */
       
   632 	{
       
   633 public:
       
   634 	/**
       
   635 	 * Constructor that takes an algorithm identifier and saves it into the 
       
   636 	 * corresponding member variable. It is then used in the
       
   637 	 * EncodeSignatureAlgorithm() function.
       
   638 	 * 
       
   639 	 * @param aDigestAlg	Digest algorithm to use. Currently the following 
       
   640 	 * 						algorithms are supported: MD2, MD5, and SHA-1.
       
   641 	 */
       
   642 	IMPORT_C TX509KeyEncoder(TAlgorithmId aDigestAlg);
       
   643 
       
   644 	/**
       
   645 	 * Produces the SubjectPublicKeyInfo encoding. 
       
   646 	 * 
       
   647 	 * The encoding has the following ASN.1 format:
       
   648 	 * @code
       
   649 	 * SubjectPublicKeyInfo {ALGORITHM : IOSet} ::= SEQUENCE {
       
   650 	 *     algorithm        AlgorithmIdentifier {{IOSet}},
       
   651 	 *     subjectPublicKey BIT STRING
       
   652 	 *     }
       
   653 	 * @endcode
       
   654 	 */
       
   655 	IMPORT_C virtual CASN1EncBase* EncodeKeyLC() const = 0;
       
   656 
       
   657 	/**
       
   658 	 * Produces the AlgorithmIdentifier encoding.
       
   659 	 * 
       
   660 	 * @return	ASN.1 sequence containing signature algorithm
       
   661 	 */
       
   662 	IMPORT_C virtual CASN1EncSequence* EncodeSignatureAlgorithmLC() const = 0;
       
   663 
       
   664 	/**
       
   665 	 * Produces the DigestAlgorithmIdentifier encoder.
       
   666 	 *
       
   667 	 * The encoding has the following ASN.1 format
       
   668 	 * @code
       
   669      *   DigestAlgorithmIdentifier ::= SEQUENCE {
       
   670      *     algorithm AlgorithmIdentifier,
       
   671      *     parameters ANY DEFINED BY algorithm OPTIONAL }
       
   672      *
       
   673      *   AlgorithmIdentifier ::= OBJECT IDENTIFIER
       
   674 	 * @endcode
       
   675  	 *
       
   676 	 * @return Appropriate ASN.1 sequence of type <code>DigestAlgorithmIdentifier</code>
       
   677 	 */
       
   678 	IMPORT_C virtual CASN1EncSequence* EncodeDigestAlgorithmLC() const;
       
   679 
       
   680 protected:
       
   681 	/** Digest algorithm to use. */
       
   682 	TAlgorithmId iDigestAlg;
       
   683 	};
       
   684 
       
   685 class TX509RSAKeyEncoder : public TX509KeyEncoder
       
   686 /**
       
   687  * Subclasses TC509KeyEncoder to provides key encoding capability for RSA public keys.
       
   688  * 
       
   689  * This class is part of the pkcs10 API, and will be changed or removed in a
       
   690  * future release.  You should not use it.
       
   691  * 
       
   692  * @internalTechnology 
       
   693  */
       
   694 	{
       
   695 public:
       
   696 	/**
       
   697 	 * Constructs a RSA key pair encoder, saving reference to the passed 
       
   698 	 * key pair in the member variable.
       
   699 	 * 
       
   700 	 * @param aPublicKey	RSA public key to use for encoding.
       
   701 	 * @param aDigestAlg	Digest algorithm to use.
       
   702 	 */
       
   703 	IMPORT_C TX509RSAKeyEncoder(const CRSAPublicKey& aPublicKey, TAlgorithmId aDigestAlg);
       
   704 
       
   705 	/**
       
   706 	 * Produces the SubjectPublicKeyInfo encoding. 
       
   707 	 * 
       
   708 	 * The resulting encoding has the following form:
       
   709 	 * @code
       
   710 	 *     SEQUENCE-OF
       
   711 	 *         SEQUENCE-OF
       
   712 	 *             OID of the encryption algorithm (KRSA)
       
   713 	 *             NULL
       
   714 	 *         BIT STRING encoded public key.
       
   715 	 * @endcode
       
   716 	 * 
       
   717 	 * @return	DER-encoded public key information, placed on the cleanup stack.
       
   718 	 */
       
   719 	IMPORT_C virtual CASN1EncBase* EncodeKeyLC() const;
       
   720 
       
   721 	/**
       
   722 	 * Produces the AlgorithmIdentifier encoding.
       
   723   	 * 
       
   724 	 * This has the following form:
       
   725 	 * @code
       
   726 	 *     SEQUENCE-OF
       
   727 	 *         OID signature-algorithm
       
   728 	 *         NULL
       
   729 	 * @endcode
       
   730 	 * 
       
   731 	 * @return	ASN.1 sequence containing signature algorithm encoding, 
       
   732 	 * 			placed on the cleanup stack.
       
   733 	 */
       
   734 	IMPORT_C virtual CASN1EncSequence* EncodeSignatureAlgorithmLC() const;
       
   735 
       
   736 private:
       
   737 	/**
       
   738 	 * Saved reference to the RSA public key to be used for encoding.
       
   739 	 */
       
   740 	const CRSAPublicKey& iPublicKey;
       
   741 	};
       
   742 
       
   743 class TX509DSAKeyEncoder : public TX509KeyEncoder
       
   744 /**
       
   745  * Provides key encoding and signing capability using a DSA public key.
       
   746  * 
       
   747  * This class is part of the pkcs10 API, and will be changed or removed in a
       
   748  * future release.  You should not use it.
       
   749  * 
       
   750  * @internalTechnology 
       
   751  */
       
   752 	{
       
   753 public:
       
   754 	/**
       
   755 	 * Constructs a DSA key pair encoder, saving reference to the passed 
       
   756 	 * public key in the member variable.
       
   757 	 * 
       
   758 	 * @param aKeyPublic	DSA public key to use for encoding.
       
   759 	 * @param aDigestAlg	Digest algorithm to use.
       
   760 	 */
       
   761 	IMPORT_C TX509DSAKeyEncoder(const CDSAPublicKey& aKeyPublic, 
       
   762 								TAlgorithmId aDigestAlg);
       
   763 
       
   764 	/**
       
   765 	 * Produces the SubjectPublicKeyInfo encoding. 
       
   766   	 * 
       
   767 	 * The ASN.1 encoding of a DSA key has the following form:
       
   768 	 * @code
       
   769 	 * SEQUENCE-OF
       
   770 	 *     SEQUENCE-OF
       
   771 	 *         OID dsa (1.2.840.10040.4.1)
       
   772 	 *         SEQUENCE-OF
       
   773 	 *             INTEGER p
       
   774 	 *             INTEGER q
       
   775 	 *             INTEGER g
       
   776 	 *     BIT STRING
       
   777 	 *         INTEGER public value (y)
       
   778 	 * @endcode
       
   779 	 * 
       
   780 	 * @return DER-encoded public key information, placed on the cleanup stack.
       
   781 	 */
       
   782 	IMPORT_C virtual CASN1EncBase* EncodeKeyLC() const;
       
   783 
       
   784 	/**
       
   785 	 * Produces the AlgorithmIdentifier encoding.
       
   786    	 * 
       
   787 	 * This has the following form:
       
   788 	 * @code
       
   789 	 * SEQUENCE-OF
       
   790 	 *     OID dsa-signature-oid
       
   791 	 *     SEQUENCE-OF dsa-params
       
   792 	 *         INTEGER p
       
   793 	 *         INTEGER q
       
   794 	 *         INTEGER g
       
   795 	 * @endcode
       
   796 	 * 
       
   797 	 * @return	ASN.1 sequence containing signature algorithm encoding, 
       
   798 	 *     		placed on the cleanup stack.
       
   799 	 */
       
   800 	IMPORT_C virtual CASN1EncSequence* EncodeSignatureAlgorithmLC() const;
       
   801 
       
   802 private:
       
   803 	/**
       
   804 	 * Saved reference to the DSA public key to be used for encoding.
       
   805 	 */
       
   806 	const CDSAPublicKey& iPublicKey;
       
   807 	};
       
   808 
       
   809 #endif
   601 #endif