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: * X.509 key classes and utility classes for key encoding/decoding. 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: #if !defined (__X509KEYS_H__) williamr@2: #define __X509KEYS_H__ williamr@2: williamr@2: #include williamr@2: #include williamr@2: #include williamr@2: #include williamr@2: #include williamr@2: #include williamr@2: #include williamr@2: williamr@2: // Forward declarations williamr@2: class CASN1EncBase; williamr@2: class CASN1EncContainer; williamr@2: class CASN1EncSequence; williamr@2: class CASN1EncBitString; williamr@2: williamr@4: williamr@4: #ifndef SYMBIAN_ENABLE_SPLIT_HEADERS williamr@4: #include williamr@4: #endif williamr@4: williamr@2: class CX509RSAPublicKey : public CRSAPublicKey williamr@2: /** Adds the capability to decode DER-encoded RSA public keys. williamr@2: * williamr@2: * Adds a commitment to a specific encoding scheme allowing X.509 RSA public key williamr@2: * superclasses to remain encoding-independent. williamr@2: * williamr@2: * williamr@2: * @since v6.0 williamr@2: */ williamr@2: { williamr@2: public: williamr@2: /** Creates a new RSA Public key object from the specified buffer containing the williamr@2: * encoded binary representation. williamr@2: * williamr@2: * Initialises the object from its encoded binary form into an internal representation. williamr@2: * williamr@2: * @param aBinaryData The encoded binary representation. williamr@2: * @return A pointer to the new CX509RSAPublicKey object. */ williamr@2: IMPORT_C static CX509RSAPublicKey* NewL(const TDesC8& aBinaryData); williamr@2: williamr@2: /** Creates a new RSA Public Key object from the specified buffer containing the williamr@2: * encoded binary representation, and puts a pointer to it onto the cleanup stack. williamr@2: * williamr@2: * @param aBinaryData The encoded binary representation. williamr@2: * @return A pointer to the new CX509RSAPublicKey object. */ williamr@2: IMPORT_C static CX509RSAPublicKey* NewLC(const TDesC8& aBinaryData); williamr@2: williamr@2: /** Creates a new RSA Public key object from the specified buffer containing the williamr@2: * encoded binary representation, starting at the specified offset. williamr@2: * williamr@2: * @param aBinaryData The encoded binary representation. williamr@2: * @param aPos The offset position from which to start decoding. williamr@2: * @return A pointer to the new CX509RSAPublicKey object. */ williamr@2: IMPORT_C static CX509RSAPublicKey* NewL(const TDesC8& aBinaryData, TInt& aPos); williamr@2: williamr@2: /** Creates a new RSA Public key object from the specified buffer containing the williamr@2: * encoded binary representation, starting at the specified offset, and puts williamr@2: * a pointer to it onto the cleanup stack. williamr@2: * williamr@2: * @param aBinaryData The encoded binary representation. williamr@2: * @param aPos The offset position from which to start decoding. williamr@2: * @return A pointer to the new CX509RSAPublicKey object. */ williamr@2: IMPORT_C static CX509RSAPublicKey* NewLC(const TDesC8& aBinaryData, TInt& aPos); williamr@2: private: williamr@2: void ConstructL(const TDesC8& aBinaryData, TInt& aPos); williamr@2: CX509RSAPublicKey(); williamr@2: }; williamr@2: williamr@2: class TASN1EncRSAPublicKey williamr@2: /** williamr@2: * Class for encoding RSA public keys to ASN.1 encoding. williamr@2: * williamr@2: * @since v8.0 williamr@2: */ williamr@2: { williamr@2: public: williamr@2: /** williamr@2: * Encodes the supplied public key into buffer in DER format ASN.1: williamr@2: * @code williamr@2: * SEQUENCE-OF williamr@2: * INTEGER modulus williamr@2: * INTEGER exponent williamr@2: * @endcode williamr@2: * williamr@2: * @param aKey Key to encode. williamr@2: * @return Allocated buffer containing DER encoding of williamr@2: * the supplied key aKey. williamr@2: */ williamr@2: IMPORT_C HBufC8* EncodeDERL(const CRSAPublicKey& aKey) const; williamr@2: }; williamr@2: williamr@2: class TASN1DecRSAPublicKey williamr@2: /** williamr@2: * Class for decoding RSA public keys from ASN.1 DER encoding. williamr@2: * williamr@2: * @since v8.0 williamr@2: */ williamr@2: { williamr@2: public: williamr@2: /** williamr@2: * Decodes an RSA key from the supplied buffer starting at the williamr@2: * specified position. williamr@2: * williamr@2: * @param aDER Buffer containing DER ASN.1 encoding of the key. williamr@2: * @param aPos Starting position in the buffer (updated on exit). williamr@2: * @return A pointer to the new CRSAPublicKey object. williamr@2: */ williamr@2: IMPORT_C CRSAPublicKey* DecodeDERL(const TDesC8& aDER, TInt& aPos) const; williamr@2: }; williamr@2: williamr@2: class TASN1DecRSAKeyPair williamr@2: /** williamr@2: * Class for decoding RSA key pairs from ASN.1 DER encoding. williamr@2: * williamr@2: * @since v8.0 williamr@2: */ williamr@2: { williamr@2: public: williamr@2: /** williamr@2: * Decodes an RSA key pair from buffer containing ASN.1 williamr@2: * DER-encoded private key. The encoding of a private key williamr@2: * contains public key components as well. williamr@2: * williamr@2: * @param aDER DER-encoded private key. williamr@2: * @param aPos Position in the buffer to start decoding williamr@2: * (updated on exit). williamr@2: * @param aPublicKey On return, the RSA public key object williamr@2: * @param aPrivateKey On return, the RSA private key object williamr@2: * @param aKeyType Key type, default is @c EStandardCRT williamr@2: */ williamr@2: IMPORT_C void DecodeDERL(const TDesC8& aDER, TInt& aPos, williamr@2: CRSAPublicKey*& aPublicKey, williamr@2: CRSAPrivateKey*& aPrivateKey, williamr@2: TRSAPrivateKeyType aKeyType = EStandardCRT); williamr@2: }; williamr@2: williamr@2: class CX509DSAPublicKey : public CDSAPublicKey williamr@2: /** Encapsulates the X.509 DSA public key. williamr@2: * williamr@2: * Adds a commitment to a specific encoding scheme allowing superclasses to remain williamr@2: * encoding-independent. williamr@2: * williamr@2: * @since v6.0 williamr@2: */ williamr@2: // DSA public key, params, signature. williamr@2: { williamr@2: public: williamr@2: /** Creates a new X.509 DSA public key object. williamr@2: * williamr@2: * @param aParamsData A non-modifiable descriptor representing the entire encoding. williamr@2: * @param aBinaryData The encoded binary representation. williamr@2: * @return A pointer to the new CX509DSAPublicKey object. */ williamr@2: IMPORT_C static CX509DSAPublicKey* NewL(const TDesC8& aParamsData, const TDesC8& aBinaryData); williamr@2: williamr@2: /** Creates a new X.509 DSA public key object, and puts a pointer to it onto the cleanup stack. williamr@2: * williamr@2: * @param aParamsData A non-modifiable descriptor representing the entire encoding. williamr@2: * @param aBinaryData The encoded binary representation. williamr@2: * @return A pointer to the new CX509DSAPublicKey object. */ williamr@2: IMPORT_C static CX509DSAPublicKey* NewLC(const TDesC8& aParamsData, const TDesC8& aBinaryData); williamr@2: williamr@2: /** Creates a new X.509 DSA public key object. williamr@2: * williamr@2: * @param aParams The DSA parameters. williamr@2: * @param aBinaryData The encoded binary representation. williamr@2: * @return A pointer to the new CX509DSAPublicKey object. */ williamr@2: IMPORT_C static CX509DSAPublicKey* NewL(const CDSAParameters& aParams, const TDesC8& aBinaryData); williamr@2: williamr@2: /** Creates a new X.509 DSA public key object, and puts a pointer to it onto the cleanup stack. williamr@2: * williamr@2: * @param aParams The DSA parameters. williamr@2: * @param aBinaryData The encoded binary representation. williamr@2: * @return A pointer to the new CX509DSAPublicKey object. */ williamr@2: IMPORT_C static CX509DSAPublicKey* NewLC(const CDSAParameters& aParams, const TDesC8& aBinaryData); williamr@2: williamr@2: /** Creates a new X.509 DSA public key object. williamr@2: * williamr@2: * @param aParamsData A non-modifiable descriptor representing the entire encoding. williamr@2: * @param aBinaryData The encoded binary representation. williamr@2: * @param aPos The position from which to start decoding. williamr@2: * @return A pointer to the new CX509DSAPublicKey object. */ williamr@2: IMPORT_C static CX509DSAPublicKey* NewL(const TDesC8& aParamsData, const TDesC8& aBinaryData,TInt& aPos); williamr@2: williamr@2: /** Creates a new X.509 DSA public key object, and puts a pointer to it onto the cleanup stack. williamr@2: * williamr@2: * @param aParamsData A non-modifiable descriptor representing the entire encoding. williamr@2: * @param aBinaryData The encoded binary representation. williamr@2: * @param aPos The position from which to start decoding. williamr@2: * @return A pointer to the new CX509DSAPublicKey object. */ williamr@2: IMPORT_C static CX509DSAPublicKey* NewLC(const TDesC8& aParamsData, const TDesC8& aBinaryData, TInt& aPos); williamr@2: williamr@2: /** Creates a new X.509 DSA public key object. williamr@2: * williamr@2: * @param aParams The DSA parameters. williamr@2: * @param aBinaryData The encoded binary representation. williamr@2: * @param aPos The position from which to start decoding. williamr@2: * @return A pointer to the new CX509DSAPublicKey object. */ williamr@2: IMPORT_C static CX509DSAPublicKey* NewL(const CDSAParameters& aParams, const TDesC8& aBinaryData, TInt& aPos); williamr@2: williamr@2: /** Creates a new X.509 DSA public key object, and puts a pointer to it onto the cleanup stack. williamr@2: * williamr@2: * @param aParams The DSA parameters. williamr@2: * @param aBinaryData The encoded binary representation. williamr@2: * @param aPos The position from which to start decoding. williamr@2: * @return A pointer to the new CX509DSAPublicKey object. */ williamr@2: IMPORT_C static CX509DSAPublicKey* NewLC(const CDSAParameters& aParams, const TDesC8& aBinaryData, TInt& aPos); williamr@2: public: williamr@2: /** Gets the DSA parameters from the encoding key. williamr@2: * williamr@2: * @param aParamsData A non-modifiable descriptor representing the entire encoding. williamr@2: * @return The DSA parameters. */ williamr@2: IMPORT_C static CDSAParameters* DSAParametersL(const TDesC8& aParamsData); williamr@2: protected: williamr@2: /** @internalComponent */ williamr@2: void ConstructL(const TDesC8& aParamsData, const TDesC8& aBinaryData, TInt& aPos); williamr@2: /** @internalComponent */ williamr@2: void ConstructL(const CDSAParameters& aParams, const TDesC8& aBinaryData, TInt& aPos); williamr@2: /** @internalComponent */ williamr@2: CX509DSAPublicKey(); williamr@2: }; williamr@2: williamr@2: class TASN1DecDSAKeyPair williamr@2: /** williamr@2: * Class for decoding DSA key pairs from ASN.1 DER encoding. williamr@2: * williamr@2: * @since v8.0 williamr@2: */ williamr@2: { williamr@2: public: williamr@2: /** williamr@2: * Decodes a DSA key pair from a buffer containing an ASN.1 williamr@2: * DER-encoded private key. williamr@2: * williamr@2: * The encoding of the private key contains public key components as well. williamr@2: * williamr@2: * The DER encoding has the following format: williamr@2: * @verbatim williamr@2: * SEQUENCE-OF williamr@2: * INTEGER version (==0, ignored) williamr@2: * INTEGER p (public prime) williamr@2: * INTEGER q (160-bit public subprime, q | p-1) williamr@2: * INTEGER g (public generator of subgroup) williamr@2: * INTEGER x (private key) williamr@2: * INTEGER y (public key y=g^x) williamr@2: * @endverbatim williamr@2: * williamr@2: * @param aDER DER-encoded private key. williamr@2: * @param aPos Position in the buffer to start decoding williamr@2: * (updated on exit). williamr@2: * @param aPublicKey On return, the DSA public key object williamr@2: * @param aPrivateKey On return, the DSA private key object williamr@2: */ williamr@2: IMPORT_C void DecodeDERL(const TDesC8& aDER, TInt& aPos, williamr@2: CDSAPublicKey*& aPublicKey, CDSAPrivateKey*& aPrivateKey); williamr@2: }; williamr@2: williamr@2: /** williamr@2: * Class for encoding DSA public keys to ASN.1 encoding. williamr@2: * williamr@2: * @since v8.0 williamr@2: */ williamr@2: class TASN1EncDSAPublicKey williamr@2: { williamr@2: public: williamr@2: /** williamr@2: * Encodes the supplied public key into a buffer in DER format. williamr@2: * williamr@2: * Note that the encoding has the following format: williamr@2: * @code williamr@2: * SEQUENCE-OF williamr@2: * SEQUENCE-OF williamr@2: * INTEGER p williamr@2: * INTEGER q williamr@2: * INTEGER g williamr@2: * BIT STRING (encoded INTEGER public value) williamr@2: * @endcode williamr@2: * williamr@2: * @param aKey Key to encode. williamr@2: * @return Sequence containing public key information. williamr@2: */ williamr@2: IMPORT_C CASN1EncSequence* EncodeDERL(const CDSAPublicKey& aKey) const; williamr@2: williamr@2: /** williamr@2: * Encodes DSA parameters into an ASN.1 encoding structure suitable for williamr@2: * inclusion into other objects, like a PKCS#10 certificate request. williamr@2: * williamr@2: * Note that the encoding has the following form: williamr@2: * @code williamr@2: * SEQUENCE-OF williamr@2: * INTEGER p williamr@2: * INTEGER q williamr@2: * INTEGER g williamr@2: * @endcode williamr@2: * williamr@2: * @param aKey DSA public key. williamr@2: * @return ASN.1 encoding structure on the cleanup stack. williamr@2: */ williamr@2: IMPORT_C CASN1EncSequence* EncodeParamsLC(const CDSAPublicKey& aKey) const; williamr@2: williamr@2: /** williamr@2: * Encodes a public key as a bit string. williamr@2: * williamr@2: * @param aKey DSA public key. williamr@2: * @return ASN.1 bit string (public key). This is left on the cleanup stack. williamr@2: */ williamr@2: williamr@2: IMPORT_C CASN1EncBitString* EncodePublicValueLC(const CDSAPublicKey& aKey) const; williamr@2: }; williamr@2: williamr@2: class CX509DSASignature : public CDSASignature williamr@2: /** Encapsulates the X.509 DSA signature. williamr@2: * williamr@2: * Adds a commitment to a specific encoding scheme allowing superclasses to remain williamr@2: * encoding-independent. williamr@2: * williamr@2: * @since v6.0 */ williamr@2: { williamr@2: public: williamr@2: /** Creates a new DSA Signature object from the specified buffer containing the williamr@2: * encoded binary representation. williamr@2: * williamr@2: * @param aBinaryData The encoded binary representation. williamr@2: * @return A pointer to the new CX509DSASignature object. */ williamr@2: IMPORT_C static CX509DSASignature* NewL(const TDesC8& aBinaryData); williamr@2: williamr@2: /** Creates a new DSA Signature object from the specified buffer containing the williamr@2: * encoded binary representation, and puts a pointer to it onto the cleanup stack. williamr@2: * williamr@2: * @param aBinaryData The encoded binary representation. williamr@2: * @return A pointer to the new CX509DSASignature object. */ williamr@2: IMPORT_C static CX509DSASignature* NewLC(const TDesC8& aBinaryData); williamr@2: williamr@2: /** Creates a new DSA Signature object from the specified buffer containing the williamr@2: * encoded binary representation, starting at the specified offset. williamr@2: * williamr@2: * @param aBinaryData The encoded binary representation. williamr@2: * @param aPos The offset position from which to start decoding. williamr@2: * @return A pointer to the new CX509DSASignature object. */ williamr@2: IMPORT_C static CX509DSASignature* NewL(const TDesC8& aBinaryData, TInt& aPos); williamr@2: williamr@2: /** Creates a new DSA Signature object from the specified buffer containing the williamr@2: * encoded binary representation, starting at the specified offset, and puts williamr@2: * a pointer to it onto the cleanup stack. williamr@2: * williamr@2: * @param aBinaryData The encoded binary representation. williamr@2: * @param aPos The offset position from which to start decoding. williamr@2: * @return A pointer to the new CX509DSASignature object. */ williamr@2: IMPORT_C static CX509DSASignature* NewLC(const TDesC8& aBinaryData, TInt& aPos); williamr@2: private: williamr@2: void ConstructL(const TDesC8& aBinaryData, TInt& aPos); williamr@2: CX509DSASignature(); williamr@2: }; williamr@2: williamr@2: class CX509DHPublicKey : public CDHPublicKey williamr@2: /** Provides clients with the information they need for Diffie-Hellman key exchange williamr@2: * within a protocol. williamr@2: * williamr@2: * @since v6.0 */ williamr@2: { williamr@2: public: williamr@2: /** Creates a new CX509DHPublicKey object from the specified buffer containing the encoded williamr@2: * binary representation. williamr@2: * williamr@2: * @param aParamsData A non-modifiable descriptor representing the entire encoding. williamr@2: * @param aKeyData williamr@2: * @return A pointer to the new CX509DHPublicKey object.*/ williamr@2: IMPORT_C static CX509DHPublicKey* NewL(const TDesC8& aParamsData, const TDesC8& aKeyData); williamr@2: williamr@2: /** Creates a new CX509DHPublicKey object from the specified buffer containing the encoded williamr@2: * binary representation, and puts a pointer to it onto the cleanup stack. williamr@2: * williamr@2: * @param aParamsData A non-modifiable descriptor representing the entire encoding. williamr@2: * @param aKeyData williamr@2: * @return A pointer to the new CX509DHPublicKey object.*/ williamr@2: IMPORT_C static CX509DHPublicKey* NewLC(const TDesC8& aParamsData, const TDesC8& aKeyData); williamr@2: public: williamr@2: /** Destructor. williamr@2: * williamr@2: * Frees all resources owned by the object, prior to its destruction. */ williamr@2: IMPORT_C virtual ~CX509DHPublicKey(); williamr@2: protected: williamr@2: /** @internalComponent */ williamr@2: CX509DHPublicKey(); williamr@2: /** @internalComponent */ williamr@2: void ConstructL(const TDesC8& aParamsData, const TDesC8& aKeyData); williamr@2: }; williamr@2: williamr@2: class CX509DHKeyPair : public CDHKeyPair williamr@2: /** This class represents the Diffie-Hellman Key Pair. williamr@2: * williamr@2: * @since v8.0 */ williamr@2: { williamr@2: public: williamr@2: /** Creates a new DH key pair object from the specified buffer containing williamr@2: * the encoded binary representation . williamr@2: * williamr@2: * @param aParamsData A non-modifiable descriptor representing the entire encoding. williamr@2: * @return A pointer to the new CX509DHKeyPair object. williamr@2: */ williamr@2: IMPORT_C static CX509DHKeyPair* NewL(const TDesC8& aParamsData); williamr@2: williamr@2: /** Creates a new DH Key Pair object from the specified buffer containing the encoded binary williamr@2: * representation, and puts a pointer to it onto the cleanup stack. williamr@2: * williamr@2: * @param aParamsData A non-modifiable descriptor representing the entire encoding. williamr@2: * @return A pointer to the new CX509DHKeyPair object. williamr@2: */ williamr@2: IMPORT_C static CX509DHKeyPair* NewLC(const TDesC8& aParamsData); williamr@2: public: williamr@2: williamr@2: /** Virtual Destructor. williamr@2: * Frees all resources owned by the object, prior to its destruction. williamr@2: * williamr@2: */ williamr@2: IMPORT_C virtual ~CX509DHKeyPair(); williamr@2: protected: williamr@2: /** @internalComponent */ williamr@2: CX509DHKeyPair(); williamr@2: /** @internalComponent */ williamr@2: void ConstructL(const TDesC8& aParamsData); williamr@2: }; williamr@2: williamr@2: class CX509DHValidationParams : public CBase williamr@2: /** Validates Diffie-Hellman (DH) Domain parameters. williamr@2: * williamr@2: * Provides access to the DH Validation Parameters, which are used to determine williamr@2: * if the DH Public Key has been generated in conformance with the algorithm williamr@2: * specified in ESDH (see RFC 2631). williamr@2: * williamr@2: * @since v6.0 */ williamr@2: { williamr@2: public: williamr@2: /** Creates a new DH Validation parameters object from the specified buffer containing williamr@2: * the encoded binary representation. williamr@2: * williamr@2: * @param aBinaryData The encoded binary representation. williamr@2: * @return A pointer to the new CX509DHValidationParams object. */ williamr@2: IMPORT_C static CX509DHValidationParams* NewL(const TDesC8& aBinaryData); williamr@2: williamr@2: /** Creates a new DH Validation parameters object from the specified buffer containing williamr@2: * the encoded binary representation, and puts a pointer to it onto the cleanup stack. williamr@2: * williamr@2: * @param aBinaryData The encoded binary representation. williamr@2: * @return A pointer to the new CX509DHValidationParams object. */ williamr@2: IMPORT_C static CX509DHValidationParams* NewLC(const TDesC8& aBinaryData); williamr@2: williamr@2: /** Creates a new DH Validation parameters object from the specified buffer containing williamr@2: * the encoded binary representation, starting at the specified offset. williamr@2: * williamr@2: * @param aBinaryData The encoded binary representation. williamr@2: * @param aPos The offset position from which to start decoding. williamr@2: * @return A pointer to the new CX509DHValidationParams object. */ williamr@2: IMPORT_C static CX509DHValidationParams* NewL(const TDesC8& aBinaryData, TInt& aPos); williamr@2: williamr@2: /** Creates a new DH Validation parameters object from the specified buffer containing williamr@2: * the encoded binary representation, starting at the specified offset, and puts williamr@2: * a pointer to it onto the cleanup stack. williamr@2: * williamr@2: * @param aBinaryData The encoded binary representation. williamr@2: * @param aPos The offset position from which to start decoding. williamr@2: * @return A pointer to the new CX509DHValidationParams object. */ williamr@2: IMPORT_C static CX509DHValidationParams* NewLC(const TDesC8& aBinaryData, TInt& aPos); williamr@2: williamr@2: /** Gets a DSA prime generation seed. williamr@2: * williamr@2: * @return The bit string parameter used as the seed. */ williamr@2: IMPORT_C const TPtrC8 Seed() const; williamr@2: williamr@2: /** Gets the output from a DSA prime generation counter. williamr@2: * williamr@2: * @return The integer value output. */ williamr@2: IMPORT_C const TInteger& PGenCounter() const; williamr@2: williamr@2: /** Destructor. williamr@2: * williamr@2: * Frees all resources owned by the object, prior to its destruction. */ williamr@2: virtual ~CX509DHValidationParams(); williamr@2: protected: williamr@2: /** @internalComponent */ williamr@2: CX509DHValidationParams(); williamr@2: /** @internalComponent */ williamr@2: void ConstructL(const TDesC8& aBinaryData, TInt& aPos); williamr@2: HBufC8* iSeed; williamr@2: RInteger iPGenCounter; williamr@2: }; williamr@2: williamr@2: class CX509DHDomainParams : public CBase williamr@2: /** Encapsulates the compulsory Diffie-Hellman domain parameter values P and G williamr@2: * (See RFC 2459). williamr@2: * williamr@2: * @since v6.0 */ williamr@2: { williamr@2: public: williamr@2: /** Creates a new DH Domain parameters object from the specified buffer containing williamr@2: * the encoded binary representation. williamr@2: * williamr@2: * @param aBinaryData The encoded binary representation. williamr@2: * @return A pointer to the new CX509DHDomainParams object. */ williamr@2: IMPORT_C static CX509DHDomainParams* NewL(const TDesC8& aBinaryData); williamr@2: williamr@2: /** Creates a new DH Domain parameters object from the specified buffer containing williamr@2: * the encoded binary representation, and puts a pointer to it onto the cleanup stack. williamr@2: * williamr@2: * @param aBinaryData The encoded binary representation. williamr@2: * @return A pointer to the new CX509DHDomainParams object. */ williamr@2: IMPORT_C static CX509DHDomainParams* NewLC(const TDesC8& aBinaryData); williamr@2: williamr@2: /** Creates a new DH Domain parameters object from the specified buffer containing williamr@2: * the encoded binary representation, starting at the specified offset. williamr@2: * williamr@2: * @param aBinaryData The encoded binary representation. williamr@2: * @param aPos The offset position from which to start decoding. williamr@2: * @return A pointer to the new CX509DHDomainParams object. */ williamr@2: IMPORT_C static CX509DHDomainParams* NewL(const TDesC8& aBinaryData, TInt& aPos); williamr@2: williamr@2: /** Creates a new DH Domain parameters object from the specified buffer containing williamr@2: * the encoded binary representation, starting at the specified offset, and puts williamr@2: * a pointer to it onto the cleanup stack. williamr@2: * williamr@2: * @param aBinaryData The encoded binary representation. williamr@2: * @param aPos The offset position from which to start decoding. williamr@2: * @return A pointer to the new CX509DHDomainParams object. */ williamr@2: IMPORT_C static CX509DHDomainParams* NewLC(const TDesC8& aBinaryData, TInt& aPos); williamr@2: williamr@2: /** Gets the compulsory parameter value P. williamr@2: * williamr@2: * @return The compulsory parameter value P. */ williamr@2: IMPORT_C const TInteger& P() const; williamr@2: williamr@2: /** Gets the compulsory parameter value G. williamr@2: * williamr@2: * @return The compulsory parameter value G. */ williamr@2: IMPORT_C const TInteger& G() const; williamr@2: williamr@2: //the next 3 members are optional, in which case NULL is returned williamr@2: //the returned objects remain the property of this object williamr@2: williamr@2: //N.B. according to RFC 2459 the Q member is *not* optional, williamr@2: //however it is not essential for doing DH, and empirical studies williamr@2: //suggest it doesn't get included much, so I'm relaxing the spec here williamr@2: //to permit DomainParams objects which contain no Q. williamr@2: williamr@2: /** Gets the optional value Q. williamr@2: * williamr@2: * @return The optional value Q. */ williamr@2: IMPORT_C const TInteger& Q() const; williamr@2: williamr@2: /** Gets the optional value J. williamr@2: * williamr@2: * @return The optional value J. */ williamr@2: IMPORT_C const TInteger& J() const; williamr@2: williamr@2: /** Gets the optional validation parameters. williamr@2: * williamr@2: * @return The optional validation parameters. */ williamr@2: IMPORT_C const CX509DHValidationParams* ValidationParams() const; williamr@2: williamr@2: /** Destructor. williamr@2: * williamr@2: * Frees all resources owned by the object, prior to its destruction. */ williamr@2: virtual ~CX509DHDomainParams(); williamr@2: protected: williamr@2: /** @internalComponent */ williamr@2: CX509DHDomainParams(); williamr@2: /** @internalComponent */ williamr@2: void ConstructL(const TDesC8& aBinaryData, TInt& aPos); williamr@2: RInteger iP; williamr@2: RInteger iG; williamr@2: RInteger iQ; williamr@2: RInteger iJ; williamr@2: CX509DHValidationParams* iValidationParams; williamr@2: }; williamr@2: williamr@2: #endif