コード例 #1
0
 internal override bool TryExportKey(
     ReadOnlySpan <byte> key,
     KeyBlobFormat format,
     Span <byte> blob,
     out int blobSize)
 {
     return(format switch
     {
         KeyBlobFormat.RawSymmetricKey => RawKeyFormatter.TryExport(key, blob, out blobSize),
         KeyBlobFormat.NSecSymmetricKey => NSecKeyFormatter.TryExport(NSecBlobHeader, KeySize, MacSize, key, blob, out blobSize),
         _ => throw Error.Argument_FormatNotSupported(nameof(format), format.ToString()),
     });
コード例 #2
0
        internal override bool TryExportKey(
            ReadOnlySpan <byte> key,
            KeyBlobFormat format,
            Span <byte> blob,
            out int blobSize)
        {
            switch (format)
            {
            case KeyBlobFormat.RawSymmetricKey:
                return(RawKeyFormatter.TryExport(key, blob, out blobSize));

            case KeyBlobFormat.NSecSymmetricKey:
                return(NSecKeyFormatter.TryExport(NSecBlobHeader, KeySize, MacSize, key, blob, out blobSize));

            default:
                throw Error.Argument_FormatNotSupported(nameof(format), format.ToString());
            }
        }
コード例 #3
0
        internal override bool TryImportKey(
            ReadOnlySpan <byte> blob,
            KeyBlobFormat format,
            MemoryPool <byte> memoryPool,
            out ReadOnlyMemory <byte> memory,
            out IMemoryOwner <byte>?owner,
            out PublicKey?publicKey)
        {
            publicKey = null;

            switch (format)
            {
            case KeyBlobFormat.RawSymmetricKey:
                return(RawKeyFormatter.TryImport(KeySize, blob, memoryPool, out memory, out owner));

            case KeyBlobFormat.NSecSymmetricKey:
                return(NSecKeyFormatter.TryImport(NSecBlobHeader, KeySize, MacSize, blob, memoryPool, out memory, out owner));

            default:
                throw Error.Argument_FormatNotSupported(nameof(format), format.ToString());
            }
        }