Esempio n. 1
0
        public async Task <byte[]> ExportKeyAsync()
        {
            AnswerOrError response = await KeyHandle.Module.InvokeAsync <AnswerOrError>(
                "exportSecretKey",
                new object[]
            {
                KeyHandle.Name,
            });

            return(response.GetAnswerFromBase64());
        }
Esempio n. 2
0
        private async Task <byte[]> ComputeHashAsync(string algorithm, byte[] input)
        {
            AnswerOrError ret = await(await GetModule()).InvokeAsync <AnswerOrError>(
                "computeDigest",
                new object[]
            {
                algorithm,
                Convert.ToBase64String(input),
            });

            return(ret.GetAnswerFromBase64());
        }
Esempio n. 3
0
        private async Task <byte[]> ComputeHashAsyncCore(byte[] data)
        {
            string base64Data = Convert.ToBase64String(data);

            AnswerOrError response = await KeyHandle.Module.InvokeAsync <AnswerOrError>(
                "computeHmac",
                new object[]
            {
                KeyHandle.Name,
                base64Data,
            });

            return(response.GetAnswerFromBase64());
        }
        protected async Task <byte[]> SignDataAsyncCore(ReadOnlyMemory <byte> data)
        {
            string base64Data = Convert.ToBase64String(data.Span);

            AnswerOrError response = await KeyHandle.Module.InvokeAsync <AnswerOrError>(
                "signData",
                new object[]
            {
                KeyHandle.Name,
                AlgorithmName,
                base64Data,
            });

            return(response.GetAnswerFromBase64());
        }
        protected async Task <bool> VerifyDataAsyncCore(
            ReadOnlyMemory <byte> data,
            ReadOnlyMemory <byte> signature)
        {
            string base64Data      = Convert.ToBase64String(data.Span);
            string base64Signature = Convert.ToBase64String(signature.Span);

            AnswerOrError response = await KeyHandle.Module.InvokeAsync <AnswerOrError>(
                "verifyData",
                new object[]
            {
                KeyHandle.Name,
                AlgorithmName,
                base64Data,
                base64Signature,
            });

            return(response.GetAnswerFromBoolean());
        }
        private async Task <byte[]> EncryptOrDecryptAsync(string operation, byte[] data, byte[] iv)
        {
            string base64Data = Convert.ToBase64String(data);
            string base64Iv   = null;

            if (iv != null)
            {
                base64Iv = Convert.ToBase64String(iv);
            }

            AnswerOrError response = await KeyHandle.Module.InvokeAsync <AnswerOrError>(
                operation,
                new object[]
            {
                KeyHandle.Name,
                base64Data,
                base64Iv,
                AlgorithmName
            });

            return(response.GetAnswerFromBase64());
        }