/// <summary> /// Восстановления по данным обмена симметричного ключа /// на основе <a href="http://www.ietf.org/rfc/rfc4490">ГОСТ Р 34.10 /// транспорта</a>. /// </summary> /// /// <param name="transport"> Зашифрованные данные обмена /// ключами.</param> /// <param name="keyWrapMethod">Алгоритм симметричного экспорта</param> /// /// <returns>Симметричный ключ.</returns> /// /// <argnull name="transport" /> public SymmetricAlgorithm DecryptKeyExchange( GostKeyTransport transport, GostKeyWrapMethod keyWrapMethod = GostKeyWrapMethod.CryptoPro12KeyWrap) { GostSharedSecretAlgorithm agree; switch (_gostAlgorithmType) { case CspAlgorithmType.Gost2001: { agree = ((Gost3410)_gostKey).CreateAgree(transport.TransportParameters); break; } case CspAlgorithmType.Gost2012_256: { agree = ((Gost3410_2012_256)_gostKey).CreateAgree(transport.TransportParameters); break; } case CspAlgorithmType.Gost2012_512: { agree = ((Gost3410_2012_512)_gostKey).CreateAgree(transport.TransportParameters); break; } default: { throw new NotSupportedException(); } } return(agree.Unwrap(transport.SessionEncryptedKey.GetXmlWrappedKey(), keyWrapMethod)); }
/// <summary> /// Восстановления по данным обмена симметричного ключа /// на основе <a href="http://www.ietf.org/rfc/rfc4490">ГОСТ Р 34.10 /// транспорта</a>. /// </summary> /// /// <param name="data"> Зашифрованные данные обмена /// ключами.</param> /// /// <returns>Симметричный ключ.</returns> /// /// <argnull name="data" /> public SymmetricAlgorithm DecryptKeyExchangeData(byte[] data) { if (data == null) { throw new ArgumentNullException("data"); } GostKeyTransport transport = new GostKeyTransport(); transport.Decode(data); return(DecryptKeyExchange(transport)); }
/// <summary> /// Формирование данных обмена, на основе симметричного /// ключа шифрования сообщения ГОСТ 28147. /// </summary> /// /// <param name="alg">Симметричный ключ ГОСТ 28147.</param> /// <param name="wrapMethod">Алгоритм экспорта</param> /// <returns>Зашифрованные данные для отправки стороне /// получателю.</returns> /// /// <argnull name="alg" /> public byte[] CreateKeyExchangeData(SymmetricAlgorithm alg, GostKeyWrapMethod wrapMethod = GostKeyWrapMethod.CryptoPro12KeyWrap) { GostKeyTransport transport = CreateKeyExchange(alg, wrapMethod); return(transport.Encode()); }