コード例 #1
0
        public static byte[] EncodeEncryptionParamSet(string encryptionParamSet)
        {
            if (encryptionParamSet == null)
            {
                throw ExceptionUtility.ArgumentNull("encryptionParamSet");
            }

            byte[] data;

            try
            {
                var asnEncoder = new Asn1BerEncodeBuffer();
                var parameters = new Gost2814789BlobParameters { EncryptionParamSet = CreateEncryptionParamSet(encryptionParamSet) };
                parameters.Encode(asnEncoder);

                data = asnEncoder.MsgCopy;
            }
            catch (Exception exception)
            {
                throw ExceptionUtility.CryptographicException(exception, Resources.Asn1EncodeError, typeof(Gost2814789BlobParameters).FullName);
            }

            return data;
        }
コード例 #2
0
        public static string DecodeEncryptionParamSet(byte[] data)
        {
            if (data == null)
            {
                throw ExceptionUtility.ArgumentNull("data");
            }

            string encryptionParamSet;

            try
            {
                var asnDecoder = new Asn1BerDecodeBuffer(data);
                var parameters = new Gost2814789BlobParameters();
                parameters.Decode(asnDecoder);

                encryptionParamSet = Asn1ObjectIdentifier.ToOidString(parameters.EncryptionParamSet);
            }
            catch (Exception exception)
            {
                throw ExceptionUtility.CryptographicException(exception, Resources.Asn1DecodeError, typeof(Gost2814789BlobParameters).FullName);
            }

            return encryptionParamSet;
        }