Esempio n. 1
0
        private SubjectPublicKeyInfo EncodePublicKey(Gost_R3410_KeyExchangeParams transportParameters)
        {
            var asnEncoder = new Asn1BerEncodeBuffer();
            var publicKey  = new Asn1OctetString(transportParameters.PublicKey);

            publicKey.Encode(asnEncoder);

            var publicKeyValue = asnEncoder.MsgCopy;

            var publicKeyInfo = new SubjectPublicKeyInfo
            {
                SubjectPublicKey = new Asn1BitString(publicKeyValue.Length * 8, publicKeyValue)
            };

            var publicKeyParams = CreatePublicKeyParams();

            publicKeyParams.PublicKeyParamSet  = new Asn1ObjectIdentifier(OidValue.FromString(transportParameters.PublicKeyParamSet));
            publicKeyParams.DigestParamSet     = new Asn1ObjectIdentifier(OidValue.FromString(transportParameters.DigestParamSet));
            publicKeyParams.EncryptionParamSet = Gost_28147_89_ParamSet.FromString(transportParameters.EncryptionParamSet);

            asnEncoder.Reset();
            publicKeyParams.Encode(asnEncoder);

            var publicKeyAlgOid = new Asn1ObjectIdentifier(KeyAlgorithm);

            publicKeyInfo.Algorithm = new AlgorithmIdentifier(publicKeyAlgOid, new Asn1OpenType(asnEncoder.MsgCopy));

            return(publicKeyInfo);
        }
 protected Gost_R3410_KeyExchangeParams(Gost_R3410_KeyExchangeParams other)
 {
     DigestParamSet     = other.DigestParamSet;
     PublicKeyParamSet  = other.PublicKeyParamSet;
     EncryptionParamSet = other.EncryptionParamSet;
     PublicKey          = other.PublicKey;
     PrivateKey         = other.PrivateKey;
 }