Exemple #1
0
        protected override void Serialize(
            SecureMemoryHandle keyHandle,
            Span <byte> span)
        {
            Debug.Assert(keyHandle.Size == crypto_scalarmult_curve25519_SCALARBYTES);
            Debug.Assert(span.Length == crypto_scalarmult_curve25519_SCALARBYTES);

            keyHandle.CopyTo(span);
        }
Exemple #2
0
        public static bool TryExport(
            SecureMemoryHandle keyHandle,
            Span <byte> blob,
            out int blobSize)
        {
            blobSize = keyHandle.Size;

            if (blob.Length < blobSize)
            {
                return(false);
            }

            keyHandle.CopyTo(blob);
            return(true);
        }
Exemple #3
0
        public static bool TryExport(
            uint blobHeader,
            int keySize,
            int outputSize,
            SecureMemoryHandle keyHandle,
            Span <byte> blob,
            out int blobSize)
        {
            Debug.Assert(keyHandle.Size == keySize);

            blobSize = sizeof(uint) + sizeof(short) + sizeof(short) + keySize;

            if (blob.Length < blobSize)
            {
                return(false);
            }

            BinaryPrimitives.WriteUInt32BigEndian(blob, blobHeader);
            BinaryPrimitives.WriteInt16LittleEndian(blob.Slice(sizeof(uint)), (short)keySize);
            BinaryPrimitives.WriteInt16LittleEndian(blob.Slice(sizeof(uint) + sizeof(short)), (short)outputSize);
            keyHandle.CopyTo(blob.Slice(sizeof(uint) + sizeof(short) + sizeof(short), keySize));
            return(true);
        }