williamr@2: /* williamr@2: * Copyright (c) 1998-2009 Nokia Corporation and/or its subsidiary(-ies). williamr@2: * All rights reserved. williamr@2: * This component and the accompanying materials are made available williamr@2: * under the terms of the License "Eclipse Public License v1.0" williamr@2: * which accompanies this distribution, and is available williamr@2: * at the URL "http://www.eclipse.org/legal/epl-v10.html". williamr@2: * williamr@2: * Initial Contributors: williamr@2: * Nokia Corporation - initial contribution. williamr@2: * williamr@2: * Contributors: williamr@2: * williamr@2: * Description: williamr@2: * williamr@2: */ williamr@2: williamr@2: williamr@2: /** williamr@2: @file williamr@4: @publishedAll williamr@4: @released williamr@2: */ williamr@2: williamr@2: #ifndef __SIGNED_H__ williamr@2: #define __SIGNED_H__ williamr@2: williamr@2: #include williamr@2: #include williamr@2: #include williamr@2: #include williamr@2: williamr@2: class CRSAPublicKey; williamr@2: class CDSAPublicKey; williamr@2: class CDSASignature; williamr@2: class CDSAParameters; williamr@2: williamr@2: /** Enumerates the identity of the algorithm. williamr@2: * williamr@2: */ williamr@2: enum TAlgorithmId williamr@2: { williamr@2: /** An RSA algorithm. */ williamr@2: ERSA, williamr@2: /** A DSA algorithm. */ williamr@2: EDSA, williamr@2: /** A DH algorithm. */ williamr@2: EDH, williamr@2: /** A MD2 algorithm. */ williamr@2: EMD2, williamr@2: /** A MD5 algorithm. */ williamr@2: EMD5, williamr@2: /** A SHA-1 algorithm. */ williamr@4: ESHA1, williamr@4: /** A SHA-224 algorithm. */ williamr@4: ESHA224, williamr@4: /** A SHA-256 algorithm. */ williamr@4: ESHA256, williamr@4: /** A SHA-384 algorithm. */ williamr@4: ESHA384, williamr@4: /** A SHA-512 algorithm. */ williamr@4: ESHA512 williamr@2: }; williamr@2: williamr@2: class CValidityPeriod : public CBase williamr@2: /** The period for which the certificate is valid. williamr@2: * williamr@2: * @since v6.0 */ williamr@2: { williamr@2: public: williamr@2: /** Tests whether the specified date and time is within the validity period. williamr@2: * williamr@2: * @param aTime The date and time to be tested. williamr@2: * @return ETrue, if the date and time is within the validity period; williamr@2: * EFalse, otherwise. */ williamr@2: IMPORT_C TBool Valid(const TTime& aTime) const; williamr@2: williamr@2: /** Gets the start of the validity period. williamr@2: * williamr@2: * @return The start date and time. */ williamr@2: IMPORT_C const TTime& Start() const; williamr@2: williamr@2: /** Gets the end of the validity period. williamr@2: * williamr@2: * @return The end date and time. */ williamr@2: IMPORT_C const TTime& Finish() const; williamr@2: williamr@2: /** Copy constructor. williamr@2: * williamr@2: * @param aValidityPeriod The validity period object to be copied. */ williamr@2: IMPORT_C CValidityPeriod(const CValidityPeriod& aValidityPeriod); williamr@2: williamr@2: protected: williamr@2: /** Default constructor. */ williamr@2: IMPORT_C CValidityPeriod(); williamr@2: williamr@2: /** The start time of the validity period. */ williamr@2: TTime iStart; williamr@2: williamr@2: /** The end time of the validity period. */ williamr@2: TTime iFinish; williamr@2: }; williamr@2: williamr@2: class CAlgorithmIdentifier : public CBase williamr@2: /** Contains an algorithm ID and any encoded parameters required by that algorithm. williamr@2: * williamr@2: * An object of this type creates and owns a heap descriptor to contain the encoded williamr@2: * parameters. williamr@2: * williamr@2: * @since v6.0 */ williamr@2: { williamr@2: public: williamr@2: /** Creates a new algorithm ID object copied from an existing object. williamr@2: * williamr@2: * @param aAlgorithmIdentifier The algorithm ID object to be copied. williamr@2: * @return A pointer to the new algorithm ID object. */ williamr@2: IMPORT_C static CAlgorithmIdentifier* NewL(const CAlgorithmIdentifier& aAlgorithmIdentifier); williamr@2: williamr@2: /** Creates a new algorithm ID object copied from an existing object, and puts williamr@2: * a pointer to the new object onto the cleanup stack. williamr@2: * williamr@2: * @param aAlgorithmIdentifier The algorithm ID object to be copied. williamr@2: * @return A pointer to the new algorithm ID object. */ williamr@2: IMPORT_C static CAlgorithmIdentifier* NewLC(const CAlgorithmIdentifier& aAlgorithmIdentifier); williamr@2: williamr@2: /** Creates a new algorithm ID object. williamr@2: * williamr@2: * @param aAlgorithmId The algorithm ID. williamr@2: * @param aEncodedParams The encoded parameters. williamr@2: * @return A pointer to the new algorithm ID object. */ williamr@2: IMPORT_C static CAlgorithmIdentifier* NewL(TAlgorithmId& aAlgorithmId, const TDesC8& aEncodedParams); williamr@2: williamr@2: /** Creates a new algorithm ID object, and puts a pointer to the new object onto williamr@2: * the cleanup stack. williamr@2: * williamr@2: * @param aAlgorithmId The algorithm ID. williamr@2: * @param aEncodedParams The encoded parameters. williamr@2: * @return A pointer to the new algorithm ID object. */ williamr@2: IMPORT_C static CAlgorithmIdentifier* NewLC(TAlgorithmId& aAlgorithmId, const TDesC8& aEncodedParams); williamr@2: williamr@2: /** Tests whether this algorithm identifier object is equal to the specified algorithm williamr@2: * identifier object. williamr@2: * williamr@2: * @param aAlgorithmIdentifier The algorithm identifier object to be compared. williamr@2: * @return ETrue, if this algorithm identifier object is equal to the specified williamr@2: * algorithm identifier object; EFalse otherwise. */ williamr@2: IMPORT_C TBool operator == (const CAlgorithmIdentifier& aAlgorithmIdentifier) const; williamr@2: williamr@2: /** Gets the algorithm identifier. williamr@2: * williamr@2: * @return The algorithm identifier. */ williamr@2: IMPORT_C TAlgorithmId Algorithm() const; //ID for the algorithm williamr@2: williamr@2: /** Gets the encoded parameters for the algorithm identifier. williamr@2: * williamr@2: * Note that this object owns the heap descriptor that owns the encoded parameters. williamr@2: * williamr@2: * @return The encoded parameters. */ williamr@2: IMPORT_C TPtrC8 EncodedParams() const; //the encoded parameters williamr@2: williamr@2: /** Destructor. williamr@2: * williamr@2: * Frees all resources owned by the object. */ williamr@2: IMPORT_C ~CAlgorithmIdentifier(); williamr@2: williamr@2: protected: williamr@2: /** Default constructor. */ williamr@2: IMPORT_C CAlgorithmIdentifier(); williamr@2: williamr@2: /** Constructor taking the specified parameters. williamr@2: * williamr@2: * @param aAlgorithmId The algorithm ID. */ williamr@2: IMPORT_C CAlgorithmIdentifier(TAlgorithmId& aAlgorithmId); williamr@2: williamr@2: /** Second-phase constructor taking an existing algorithm identifier object. williamr@2: * williamr@2: * @param aAlgorithmIdentifier The algorithm identifier object. */ williamr@2: IMPORT_C virtual void ConstructL(const CAlgorithmIdentifier& aAlgorithmIdentifier); williamr@2: williamr@2: /** Second-phase constructor taking encoded parameters. williamr@2: * williamr@2: * @param aEncodedParams The encoded parameters. */ williamr@2: IMPORT_C virtual void ConstructL(const TDesC8& aEncodedParams); williamr@2: williamr@2: /** The algorithm ID. */ williamr@2: TAlgorithmId iAlgorithmId; williamr@2: williamr@2: /** The encoded parameters for the algorithm ID. */ williamr@2: HBufC8* iEncodedParams; williamr@2: }; williamr@2: williamr@2: class CSigningAlgorithmIdentifier : public CBase williamr@2: /** Contains two CAlgorithmIdentifier objects for comparison purposes. williamr@2: * williamr@2: * Implements an equality operator. williamr@2: * williamr@2: * @since v6.0 */ williamr@2: { williamr@2: public: williamr@2: /** Constructs a new Signing Algorithm Identifier object, copying an existing Signing williamr@2: * Algorithm Identifier object. williamr@2: * williamr@2: * @param aSigningAlgorithmIdentifier The Signing Algorithm Identifier object. williamr@2: * @return The new Signing Algorithm Identifier object. */ williamr@2: IMPORT_C static CSigningAlgorithmIdentifier* NewL(const CSigningAlgorithmIdentifier& aSigningAlgorithmIdentifier); williamr@2: williamr@2: /** Constructs a new Signing Algorithm Identifier object, copying an existing Signing williamr@2: * Algorithm Identifier object, and puts a pointer to it onto the cleanup stack. williamr@2: * williamr@2: * @param aSigningAlgorithmIdentifier The Signing Algorithm Identifier object. williamr@2: * @return The new Signing Algorithm Identifier object. */ williamr@2: IMPORT_C static CSigningAlgorithmIdentifier* NewLC(const CSigningAlgorithmIdentifier& aSigningAlgorithmIdentifier); williamr@2: williamr@2: /** Tests whether the Signing Algorithm Identifier object is equal to the specified williamr@2: * Signing Algorithm Identifier object. williamr@2: * williamr@2: * @param aSigningAlgorithmIdentifier The Signing Algorithm Identifier object to be compared. williamr@2: * @return ETrue, if this object's Signing Algorithm Identifier value williamr@2: * is equal to the specified Signing Algorithm Identifier williamr@2: * object's value; EFalse, otherwise. */ williamr@2: IMPORT_C TBool operator == (const CSigningAlgorithmIdentifier& aSigningAlgorithmIdentifier) const; williamr@2: williamr@2: /** Gets the signature ID of the asymmetric algorithm. williamr@2: * williamr@2: * @return The signature ID of the asymmetric algorithm. */ williamr@2: IMPORT_C const CAlgorithmIdentifier& AsymmetricAlgorithm() const; williamr@2: williamr@2: /** Gets the signature ID of the digest algorithm. williamr@2: * williamr@2: * @return The signature ID of the digest algorithm. */ williamr@2: IMPORT_C const CAlgorithmIdentifier& DigestAlgorithm() const; williamr@2: williamr@2: /** Destructor. williamr@2: * williamr@2: * Frees all resources owned by the object, prior to its destruction. */ williamr@2: IMPORT_C ~CSigningAlgorithmIdentifier(); williamr@2: williamr@2: protected: williamr@2: /** Second-phase constructor. williamr@2: * @internalAll williamr@2: */ williamr@2: void ConstructL(const CSigningAlgorithmIdentifier& aSigningAlgorithmIdentifier); williamr@2: williamr@2: /** The signature ID of the asymmetric algorithm. */ williamr@2: CAlgorithmIdentifier* iAsymmetricAlgorithm; williamr@2: williamr@2: /** The signature ID of the digest algorithm. */ williamr@2: CAlgorithmIdentifier* iDigestAlgorithm; williamr@2: }; williamr@2: williamr@2: class CSubjectPublicKeyInfo : public CBase williamr@2: /** A base class for a container that holds information about a subject public key. williamr@2: * williamr@2: * It contains the algorithm ID, the encoded public key and the encoded parameters. williamr@2: * williamr@2: * @since v6.0 williamr@2: */ williamr@2: //algorithm ID + encoded public key + encoded parameters williamr@2: { williamr@2: public: williamr@2: /** Creates a new subject public key object copied from an existing object. williamr@2: * williamr@2: * @param aSubjectPublicKeyInfo The subject public key object to be copied. williamr@2: * @return A pointer to the new public key object. */ williamr@2: IMPORT_C static CSubjectPublicKeyInfo* NewL(const CSubjectPublicKeyInfo& aSubjectPublicKeyInfo); williamr@2: williamr@2: /** Creates a new subject public key object copied from an existing object and williamr@2: * puts a pointer to the new object onto the cleanup stack. williamr@2: * williamr@2: * @param aSubjectPublicKeyInfo The subject public key object to be copied. williamr@2: * @return A pointer to the new public key object. */ williamr@2: IMPORT_C static CSubjectPublicKeyInfo* NewLC(const CSubjectPublicKeyInfo& aSubjectPublicKeyInfo); williamr@2: williamr@2: /** Gets the algorithm ID. williamr@2: * williamr@2: * @return The algorithm ID. */ williamr@2: IMPORT_C TAlgorithmId AlgorithmId() const; williamr@2: williamr@2: /** Gets the encoded parameters required by the algorithm. williamr@2: * williamr@2: * @return A non-modifiable pointer descriptor representing the encoded parameters. */ williamr@2: IMPORT_C const TPtrC8 EncodedParams() const; williamr@2: williamr@2: /** Gets the encoded public key data. williamr@2: * williamr@2: * @return A non-modifiable pointer descriptor representing the encoded public williamr@2: * key data. */ williamr@2: IMPORT_C const TPtrC8 KeyData() const; williamr@2: williamr@2: /** Destructor. williamr@2: * williamr@2: * Frees all resources owned by the object. */ williamr@2: IMPORT_C ~CSubjectPublicKeyInfo(); williamr@2: protected: williamr@2: /** Second-phase constructor. williamr@2: * williamr@2: * @param aSubjectPublicKeyInfo The subject public key object to be copied. */ williamr@2: IMPORT_C virtual void ConstructL(const CSubjectPublicKeyInfo& aSubjectPublicKeyInfo); williamr@2: williamr@2: /** The algorithm ID. */ williamr@2: CAlgorithmIdentifier* iAlgId; williamr@2: williamr@2: /** A heap descriptor representing the encoded key data. */ williamr@2: HBufC8* iEncodedKeyData; williamr@2: }; williamr@2: williamr@2: class CRSASignatureResult : public CBase williamr@2: /** The RSA public key algorithm signature result. williamr@2: * williamr@2: * Derived classes: williamr@2: * @li CWTLSRSASignatureResult williamr@2: * @li CPKCS1SignatureResult. williamr@2: * williamr@2: * @see TKeyFactory::RSASignatureResultL() williamr@2: * williamr@2: * @since v6.0 */ williamr@2: { williamr@2: public: williamr@2: /** Tests whether the signature result is valid. williamr@2: * williamr@2: * @param aResult The signature result. williamr@2: * @return ETrue if the signature result is valid, otherwise EFalse. */ williamr@2: IMPORT_C virtual TBool VerifyL(const TDesC8& aResult) = 0; williamr@2: williamr@2: /** Destructor. williamr@2: * williamr@2: * Frees all resources owned by the object. */ williamr@2: IMPORT_C ~CRSASignatureResult(); williamr@2: protected: williamr@2: /** Compares this RSA Signature Result object with the specified RSA Signature williamr@2: * Result object for equality. williamr@2: * williamr@2: * @param aResult The RSA Signature Result object to be compared. williamr@2: * @return ETrue, if they are the same; EFalse, otherwise. */ williamr@2: IMPORT_C TBool operator == (const CRSASignatureResult& aResult) const; williamr@2: williamr@2: /** The digest algorithm ID. */ williamr@2: CAlgorithmIdentifier* iDigestAlgorithm; williamr@2: williamr@2: /** A heap descriptor representing the digest algorithm. */ williamr@2: HBufC8* iDigest; williamr@2: }; williamr@2: williamr@2: //signed object williamr@2: class TKeyFactory williamr@2: /** Constructs the public key objects used for signature verification from their williamr@2: * encoded binary form. williamr@2: * williamr@2: * @since v6.0 */ williamr@2: { williamr@2: public: williamr@2: /** Gets the RSA public key. williamr@2: * williamr@2: * @param aEncoding A non-modifiable descriptor representing the entire encoding. williamr@2: * @return The RSA Public key. */ williamr@2: virtual CRSAPublicKey* RSAPublicKeyL(const TDesC8& aEncoding) const = 0; williamr@2: williamr@2: /** Gets the RSA signature result. williamr@2: * williamr@2: * @param aDigestAlgorithm The algorithm ID. williamr@2: * @param aDigest A non-modifiable descriptor representing the digest algorithm. williamr@2: * @return The RSA signature result. */ williamr@2: virtual CRSASignatureResult* RSASignatureResultL(const CAlgorithmIdentifier& aDigestAlgorithm, TDesC8& aDigest) const = 0; williamr@2: williamr@2: /** Gets the DSA public key. williamr@2: * williamr@2: * @param aParams The DSA parameters williamr@2: * @param aEncoding A non-modifiable descriptor representing the entire encoding. williamr@2: * @return The DSA public key. */ williamr@2: virtual CDSAPublicKey* DSAPublicKeyL(const CDSAParameters& aParams, const TDesC8& aEncoding) const = 0; williamr@2: williamr@2: /** Gets the digital DSA signature given an encoding key. williamr@2: * williamr@2: * @param aEncoding A non-modifiable descriptor representing the entire encoding. williamr@2: * @return The DSA signature. */ williamr@2: virtual CDSASignature* DSASignatureL(const TDesC8& aEncoding) const = 0; williamr@2: williamr@2: /** Gets the DSA parameters. williamr@2: * williamr@2: * @param aEncoding A non-modifiable descriptor representing the entire encoding. williamr@2: * @return The DSA parameters. */ williamr@2: virtual CDSAParameters* DSAParametersL(const TDesC8& aEncoding) const = 0; williamr@2: // New function for TKeyFactory API williamr@2: virtual CDSAPublicKey* DSAPublicKeyL(const TDesC8& aParamsEncoding, const TDesC8& aEncoding) const = 0; williamr@2: }; williamr@2: williamr@2: class CSigningKeyParameters : public CBase williamr@2: /** Contains the parameter information required by some signing algorithms. williamr@2: * williamr@2: * The DSA signing algorithm needs parameters as well as a key. Currently, this williamr@2: * class only contains DSA parameters. williamr@2: * williamr@2: * @since v6.0 */ williamr@2: { williamr@2: public: williamr@2: /** Creates a new signing key parameters object. williamr@2: * williamr@2: * @return A pointer to the new signing key parameters object. */ williamr@2: IMPORT_C static CSigningKeyParameters* NewL(); williamr@2: williamr@2: /** Creates a new signing key parameters object and puts a pointer to the new object williamr@2: * onto the cleanup stack. williamr@2: * williamr@2: * @return A pointer to the new signing key parameters object. */ williamr@2: IMPORT_C static CSigningKeyParameters* NewLC(); williamr@2: williamr@2: /** Creates a new signing key parameters object copied from an existing object. williamr@2: * williamr@2: * @param aParameters The signing key parameters object to be copied. williamr@2: * @return A pointer to the new parameters object. */ williamr@2: IMPORT_C static CSigningKeyParameters* NewL(const CSigningKeyParameters& aParameters); williamr@2: williamr@2: /** Creates a new signing key parameters object copied from an existing object williamr@2: * and puts a pointer to the new object onto the cleanup stack. williamr@2: * williamr@2: * @param aParameters The signing key parameters object to be copied. williamr@2: * @return A pointer to the new signing key parameters object. */ williamr@2: IMPORT_C static CSigningKeyParameters* NewLC(const CSigningKeyParameters& aParameters); williamr@2: williamr@2: /** Destructor. williamr@2: * williamr@2: * Frees all resources owned by the object. */ williamr@2: IMPORT_C ~CSigningKeyParameters(); williamr@2: williamr@2: /** Sets the DSA parameters. williamr@2: * williamr@2: * @param aParams The DSA parameters. */ williamr@2: IMPORT_C void SetDSAParamsL(const CDSAParameters& aParams); williamr@2: williamr@2: /** Gets the DSA parameters. williamr@2: * williamr@2: * @return The DSA parameters. williamr@2: * @internalAll williamr@2: */ williamr@2: const CDSAParameters* DSAParams() const; williamr@2: private: williamr@2: CSigningKeyParameters(); williamr@2: void ConstructL(const CSigningKeyParameters& aParameters); williamr@2: CDSAParameters* iDSAParams; williamr@2: }; williamr@2: williamr@2: williamr@2: class CSignedObject : public CBase williamr@2: /** Base class for certificates. williamr@2: * williamr@2: * @since v6.0 */ williamr@2: { williamr@2: public: williamr@2: /** Verifies a signature using the specified encoded key. williamr@2: * williamr@2: * @param aEncodedKey The encoded key. williamr@2: * @return ETrue if the signature is valid, otherwise EFalse. */ williamr@2: IMPORT_C TBool VerifySignatureL(const TDesC8& aEncodedKey) const; williamr@2: williamr@2: /** Verifies a signature using the specified encoded key and hash. williamr@2: * williamr@2: * @param aEncodedKey The encoded key. williamr@2: * @param aHash The hash of the data to be validated. williamr@2: * @return ETrue if the signature is valid, otherwise EFalse. */ williamr@2: IMPORT_C TBool VerifySignatureL(const TDesC8& aEncodedKey, const TDesC8& aHash) const; williamr@2: williamr@2: /** Gets the digital signature. williamr@2: * williamr@2: * @return A non-modifiable pointer descriptor representing the digital signature. */ williamr@2: IMPORT_C const TPtrC8 Signature() const; williamr@2: williamr@2: /** Gets the signed data. williamr@2: * williamr@2: * @return A non-modifiable pointer descriptor representing the signed data. */ williamr@2: IMPORT_C virtual const TPtrC8 SignedDataL() const = 0; williamr@2: williamr@2: /** Gets the fingerprint. williamr@2: * williamr@2: * The fingerprint returned is the SHA1 hash of the encoding of the entire object. williamr@2: * williamr@2: * @return A non-modifiable pointer descriptor representing the finger print. */ williamr@2: IMPORT_C const TPtrC8 Fingerprint() const; williamr@2: williamr@2: /** Gets the entire encoding. williamr@2: * williamr@2: * @return A non-modifiable pointer descriptor representing the entire encoding. */ williamr@2: IMPORT_C const TPtrC8 Encoding() const; williamr@2: williamr@2: /** Gets the signing algorithm ID used. williamr@2: * williamr@2: * @return The signing algorithm ID. */ williamr@2: IMPORT_C const CSigningAlgorithmIdentifier& SigningAlgorithm() const; williamr@2: williamr@2: /** Externalises the encoding of the entire object to a write stream. williamr@2: * williamr@2: * The fingerprint and the signed data can be regenerated after restoration. williamr@2: * williamr@2: * The presence of this function means that the standard templated operator<<() williamr@2: * can be used to externalise objects of this class. williamr@2: * williamr@2: * @param aStream Stream to which the object should be externalised. */ williamr@2: IMPORT_C virtual void ExternalizeL(RWriteStream& aStream) const; williamr@2: williamr@2: /** Internalises the encoded object from a read stream. williamr@2: williamr@2: * The class makes use of a specification-specific parser class for extracting williamr@2: * the various elements, that is provided by a subclass of CSignedObject. For williamr@2: * this reason this function is pure virtual. williamr@2: * williamr@2: * The presence of this function means that the standard templated operator>>() williamr@2: * can be used to internalise objects of this class. williamr@2: * williamr@2: * @param aStream Stream from which the contents of the field should be internalised. */ williamr@2: IMPORT_C virtual void InternalizeL(RReadStream& aStream) = 0; williamr@2: williamr@2: /** Sets the signing key parameters. williamr@2: * williamr@2: * @param aParameters The signing key parameters. */ williamr@2: IMPORT_C void SetParametersL(const CSigningKeyParameters& aParameters); williamr@2: williamr@2: /** Gets the encoded data for the specified encoded data element, in the (to be williamr@2: * signed) tbsCertificate data structure, of the signed object. williamr@2: * williamr@2: * @param aIndex The encoded data element position in the tbsCertificate data williamr@2: * structure. See the enumeration: CX509Certificate::Anonymous. williamr@2: * @return The encoded data for the specified data element of the signed object. */ williamr@2: IMPORT_C virtual const TPtrC8* DataElementEncoding(const TUint aIndex) const = 0; williamr@2: williamr@2: /** Destructor. williamr@2: * williamr@2: * Frees all resources owned by the object. */ williamr@2: IMPORT_C ~CSignedObject(); williamr@2: williamr@2: protected: williamr@2: /** Verifies a RSA signature using the specified encoded key. williamr@2: * williamr@2: * @param aEncodedKey The encoded key. williamr@2: * @return ETrue if the signature is valid, otherwise EFalse. williamr@2: * @internalAll williamr@2: */ williamr@2: TBool VerifyRSASignatureL(const TDesC8& aEncodedKey) const; williamr@2: williamr@2: /** @internalAll */ williamr@2: TBool VerifyRSASignatureL(const TDesC8& aEncodedKey, const TDesC8& aHash) const; williamr@2: williamr@2: /** A pointer to a key factory object. */ williamr@2: TKeyFactory* iKeyFactory; williamr@2: williamr@2: /** A heap descriptor representing the entire encoding. */ williamr@2: HBufC8* iEncoding; williamr@2: williamr@2: /** The digital signature. */ williamr@2: HBufC8* iSignature; williamr@2: williamr@2: /** The fingerprint. williamr@2: * williamr@2: * The SHA1 hash of the encoding of the entire object. */ williamr@2: HBufC8* iFingerprint; williamr@2: williamr@2: /** The signing key parameters */ williamr@2: CSigningKeyParameters* iParameters; williamr@2: williamr@2: /** The signing algorithm ID. */ williamr@2: CSigningAlgorithmIdentifier* iSigningAlgorithm; williamr@2: }; williamr@2: williamr@2: class CCertificate : public CSignedObject williamr@2: /** A data structure that binds a public key to a given individual. williamr@2: * williamr@2: * A certificate is a signed object, and adds a serial number, a validity period williamr@2: * and a subject public key. williamr@2: * williamr@2: * This is a base class for classes that implement certificates of particular types. williamr@2: * williamr@2: * @since v6.0 */ williamr@2: { williamr@2: public: williamr@2: /** Destructor. williamr@2: * williamr@2: * Frees all resources owned by the object. */ williamr@2: IMPORT_C ~CCertificate(); williamr@2: williamr@2: /** Gets the subject public key information. williamr@2: * williamr@2: * @return The subject public key information. */ williamr@2: IMPORT_C const CSubjectPublicKeyInfo& PublicKey() const; williamr@2: williamr@2: /** Gets the serial number. williamr@2: * williamr@2: * @return A non-modifiable pointer descriptor representing the serial number. */ williamr@2: IMPORT_C const TPtrC8 SerialNumber() const; williamr@2: williamr@2: /** Gets the validity period. williamr@2: * williamr@2: * @return The validity period. */ williamr@2: IMPORT_C const CValidityPeriod& ValidityPeriod() const; williamr@2: williamr@2: /** Tests whether a certificate is self-signed. williamr@2: * williamr@2: * @return ETrue, if it is self-signed; EFalse, otherwise. */ williamr@2: IMPORT_C virtual TBool IsSelfSignedL() const = 0; williamr@2: williamr@2: /** Gets the subject. williamr@2: * williamr@2: * @return A heap descriptor representing the subject. */ williamr@2: IMPORT_C virtual HBufC* SubjectL() const = 0; williamr@2: williamr@2: /** Gets the issuer. williamr@2: * williamr@2: * @return A heap descriptor representing the issuer. */ williamr@2: IMPORT_C virtual HBufC* IssuerL() const = 0; williamr@2: williamr@2: /** Gets the key identifier. williamr@2: * williamr@2: * @return The key identifier. */ williamr@2: IMPORT_C virtual TKeyIdentifier KeyIdentifierL() const; williamr@2: williamr@2: protected: williamr@2: /** The serial number. */ williamr@2: HBufC8* iSerialNumber; williamr@2: williamr@2: /** The validity period. */ williamr@2: CValidityPeriod* iValidityPeriod; williamr@2: williamr@2: /** The subject public key information. */ williamr@2: CSubjectPublicKeyInfo* iSubjectPublicKeyInfo; williamr@2: }; williamr@2: williamr@2: #endif