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

            return(response.GetAnswerFromBase64());
        }
Example #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());
        }
Example #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());
        }
        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());
        }