internal override void CreateKey( ReadOnlySpan <byte> seed, out SecureMemoryHandle keyHandle, out PublicKey?publicKey) { publicKey = null; keyHandle = SecureMemoryHandle.CreateFrom(seed); }
internal override void CreateKey( ReadOnlySpan <byte> seed, out SecureMemoryHandle keyHandle, out PublicKey?publicKey) { Debug.Assert(seed.Length == crypto_aead_chacha20poly1305_ietf_KEYBYTES); publicKey = null; keyHandle = SecureMemoryHandle.CreateFrom(seed); }
internal override void CreateKey( ReadOnlySpan <byte> seed, out SecureMemoryHandle keyHandle, out PublicKey?publicKey) { Debug.Assert(seed.Length >= crypto_generichash_blake2b_KEYBYTES_MIN); Debug.Assert(seed.Length <= crypto_generichash_blake2b_KEYBYTES_MAX); publicKey = null; keyHandle = SecureMemoryHandle.CreateFrom(seed); }
public static bool TryImport( int keySize, ReadOnlySpan <byte> blob, out SecureMemoryHandle?keyHandle) { if (blob.Length != keySize) { keyHandle = default; return(false); } keyHandle = SecureMemoryHandle.CreateFrom(blob); return(true); }
public static bool TryImport( uint blobHeader, int keySize, int outputSize, ReadOnlySpan <byte> blob, out SecureMemoryHandle?keyHandle) { if (blob.Length != sizeof(uint) + sizeof(short) + sizeof(short) + keySize || BinaryPrimitives.ReadUInt32BigEndian(blob) != blobHeader || BinaryPrimitives.ReadInt16LittleEndian(blob.Slice(sizeof(uint))) != keySize || BinaryPrimitives.ReadInt16LittleEndian(blob.Slice(sizeof(uint) + sizeof(short))) != outputSize) { keyHandle = default; return(false); } keyHandle = SecureMemoryHandle.CreateFrom(blob.Slice(sizeof(uint) + sizeof(short) + sizeof(short), keySize)); return(true); }
protected override unsafe void Deserialize( ReadOnlySpan <byte> span, out SecureMemoryHandle?keyHandle, out PublicKeyBytes publicKeyBytes) { if (Unsafe.SizeOf <PublicKeyBytes>() != crypto_scalarmult_curve25519_SCALARBYTES) { throw Error.InvalidOperation_InternalError(); } Debug.Assert(span.Length == crypto_scalarmult_curve25519_SCALARBYTES); keyHandle = SecureMemoryHandle.CreateFrom(span); fixed(PublicKeyBytes *q = &publicKeyBytes) { int error = crypto_scalarmult_curve25519_base(q, keyHandle); Debug.Assert(error == 0); Debug.Assert((((byte *)q)[crypto_scalarmult_curve25519_SCALARBYTES - 1] & 0x80) == 0); } }
internal override unsafe void CreateKey( ReadOnlySpan <byte> seed, out SecureMemoryHandle keyHandle, out PublicKey?publicKey) { if (Unsafe.SizeOf <PublicKeyBytes>() != crypto_scalarmult_curve25519_SCALARBYTES) { throw Error.InvalidOperation_InternalError(); } Debug.Assert(seed.Length == crypto_scalarmult_curve25519_SCALARBYTES); publicKey = new PublicKey(this); keyHandle = SecureMemoryHandle.CreateFrom(seed); fixed(PublicKeyBytes *q = publicKey) { int error = crypto_scalarmult_curve25519_base(q, keyHandle); Debug.Assert(error == 0); Debug.Assert((((byte *)q)[crypto_scalarmult_curve25519_SCALARBYTES - 1] & 0x80) == 0); } }