Inheritance: IDerivationParameters
        public virtual void Init(IDerivationParameters param)
        {
            DHKdfParameters dHKdfParameters = (DHKdfParameters)param;

            this.algorithm = dHKdfParameters.Algorithm;
            this.keySize   = dHKdfParameters.KeySize;
            this.z         = dHKdfParameters.GetZ();
        }
Example #2
0
        public virtual void Init(IDerivationParameters param)
        {
            DHKdfParameters parameters = (DHKdfParameters)param;

            this.algorithm  = parameters.Algorithm;
            this.keySize    = parameters.KeySize;
            this.z          = parameters.GetZ();         // TODO Clone?
            this.partyAInfo = parameters.GetExtraInfo(); // TODO Clone?
        }
Example #3
0
        public void Init(
            IDerivationParameters param)
        {
            DHKdfParameters parameters = (DHKdfParameters)param;

            this.algorithm = parameters.Algorithm;
            this.keySize   = parameters.KeySize;
            this.z         = parameters.GetZ();     // TODO Clone?
        }
Example #4
0
        public virtual void Init(IDerivationParameters param)
        {
            DHKdfParameters dHKdfParameters = (DHKdfParameters)param;

            algorithm  = dHKdfParameters.Algorithm;
            keySize    = dHKdfParameters.KeySize;
            z          = dHKdfParameters.GetZ();
            partyAInfo = dHKdfParameters.GetExtraInfo();
        }
        public override BigInteger CalculateAgreement(
			ICipherParameters pubKey)
        {
            BigInteger result = base.CalculateAgreement(pubKey);

            int keySize = (int) algorithms[algorithm];

            DHKdfParameters dhKdfParams = new DHKdfParameters(
                new DerObjectIdentifier(algorithm), keySize, result.ToByteArrayUnsigned());

            kdf.Init(dhKdfParams);

            byte[] keyBytes = new byte[keySize / 8];
            kdf.GenerateBytes(keyBytes, 0, keyBytes.Length);

            return new BigInteger(1, keyBytes);
        }
        public override IBigInteger CalculateAgreement(ICipherParameters pubKey)
        {
            // Note that the ec.KeyAgreement class in JCE only uses kdf in one
            // of the engineGenerateSecret methods.

            var result = base.CalculateAgreement(pubKey);

            var keySize = GeneratorUtilities.GetDefaultKeySize(_algorithm);

            var dhKdfParams = new DHKdfParameters(
                new DerObjectIdentifier(_algorithm),
                keySize,
                BigIntToBytes(result));

            _kdf.Init(dhKdfParams);

            var keyBytes = new byte[keySize / 8];
            _kdf.GenerateBytes(keyBytes, 0, keyBytes.Length);

            return new BigInteger(1, keyBytes);
        }