Add migrated to .NET 8.0 variant of Hcs.Client
This commit is contained in:
@ -0,0 +1,42 @@
|
||||
using GostCryptography.Asn1.Ber;
|
||||
using GostCryptography.Properties;
|
||||
|
||||
namespace GostCryptography.Asn1.Gost.Gost_R3410
|
||||
{
|
||||
public abstract class Gost_R3410_PublicKey : Asn1OctetString
|
||||
{
|
||||
private readonly int _keySize;
|
||||
|
||||
protected Gost_R3410_PublicKey(int keySize)
|
||||
{
|
||||
_keySize = keySize;
|
||||
}
|
||||
|
||||
public override void Decode(Asn1BerDecodeBuffer buffer, bool explicitTagging, int implicitLength)
|
||||
{
|
||||
base.Decode(buffer, explicitTagging, implicitLength);
|
||||
|
||||
if (Length != _keySize)
|
||||
{
|
||||
throw ExceptionUtility.CryptographicException(Resources.Asn1ConsVioException, nameof(Length), Length);
|
||||
}
|
||||
}
|
||||
|
||||
public override int Encode(Asn1BerEncodeBuffer buffer, bool explicitTagging)
|
||||
{
|
||||
if (Length != _keySize)
|
||||
{
|
||||
throw ExceptionUtility.CryptographicException(Resources.Asn1ConsVioException, nameof(Length), Length);
|
||||
}
|
||||
|
||||
var len = base.Encode(buffer, false);
|
||||
|
||||
if (explicitTagging)
|
||||
{
|
||||
len += buffer.EncodeTagAndLength(Tag, len);
|
||||
}
|
||||
|
||||
return len;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user