Пример #1
0
        private static DSA BuildDsaPublicKey(byte[] encodedKeyValue, byte[] encodedParameters)
        {
            SubjectPublicKeyInfoAsn spki = new SubjectPublicKeyInfoAsn
            {
                Algorithm = new AlgorithmIdentifierAsn {
                    Algorithm = Oids.Dsa, Parameters = encodedParameters
                },
                SubjectPublicKey = encodedKeyValue,
            };

            AsnWriter writer = new AsnWriter(AsnEncodingRules.DER);

            spki.Encode(writer);

            DSA dsa = new DSAOpenSsl();

            try
            {
                dsa.ImportSubjectPublicKeyInfo(writer.Encode(), out _);
                return(dsa);
            }
            catch (Exception)
            {
                dsa.Dispose();
                throw;
            }
        }
Пример #2
0
        private static DSA BuildDsaPublicKey(byte[] encodedKey, byte[] encodedParameters)
        {
            SubjectPublicKeyInfoAsn spki = new SubjectPublicKeyInfoAsn
            {
                Algorithm = new AlgorithmIdentifierAsn {
                    Algorithm = new Oid(Oids.Dsa), Parameters = encodedParameters
                },
                SubjectPublicKey = encodedKey,
            };

            using (AsnWriter writer = new AsnWriter(AsnEncodingRules.DER))
            {
                DSA dsa = new DSAOpenSsl();
                spki.Encode(writer);
                dsa.ImportSubjectPublicKeyInfo(writer.EncodeAsSpan(), out _);
                return(dsa);
            }
        }