/// <summary> /// Расшифровать информацию о ключе. /// </summary> public byte[] Encode() { byte[] data; var keyWrap = new Gost_28147_89_KeyWrap(); try { keyWrap.EncryptedKey = new Gost_28147_89_EncryptedKey { EncryptedKey = new Gost_28147_89_Key(EncryptedKey), MacKey = new Gost_28147_89_Mac(Mac) }; keyWrap.EncryptedParams = new Gost_28147_89_KeyWrapParams { EncryptionParamSet = Gost_28147_89_ParamSet.FromString(EncryptionParamSet), Ukm = new Asn1OctetString(Ukm) }; var asnEncoder = new Asn1BerEncodeBuffer(); keyWrap.Encode(asnEncoder); data = asnEncoder.MsgCopy; } catch (Exception exception) { throw ExceptionUtility.CryptographicException(exception, Resources.Asn1DecodeError, nameof(Gost_28147_89_KeyWrap)); } return(data); }
/// <summary> /// Зашифровать идентификатор OID параметров шифрования. /// </summary> public static byte[] EncodeEncryptionParamSet(string encryptionParamSet) { if (encryptionParamSet == null) { throw ExceptionUtility.ArgumentNull(nameof(encryptionParamSet)); } byte[] data; try { var parameters = new Gost_28147_89_BlobParams { EncryptionParamSet = Gost_28147_89_ParamSet.FromString(encryptionParamSet) }; var asnEncoder = new Asn1BerEncodeBuffer(); parameters.Encode(asnEncoder); data = asnEncoder.MsgCopy; } catch (Exception exception) { throw ExceptionUtility.CryptographicException(exception, Resources.Asn1EncodeError, nameof(Gost_28147_89_BlobParams)); } return(data); }