public async void CreatePlainCipherOpt()
 {
     Utils.InitialiseSessionForRandomTestApp();
     using (var handle = await CipherOpt.NewPlaintextAsync()) {
         Assert.NotNull(handle);
     }
 }
Esempio n. 2
0
        // returns data map address
        async Task <byte[]> StoreImmutableData(byte[] payload)
        {
            using (var cipherOptHandle = await _cipherOpt.NewPlaintextAsync())
            {
                using (var seWriterHandle = await _iData.NewSelfEncryptorAsync())
                {
                    await _iData.WriteToSelfEncryptorAsync(seWriterHandle, payload.ToList());

                    var dataMapAddress = await _iData.CloseSelfEncryptorAsync(seWriterHandle, cipherOptHandle);

                    return(dataMapAddress);
                }
            }
        }
        public async void WriteAndReadUsingPainText()
        {
            var data = new byte[1024];

            new Random().NextBytes(data);
            Utils.InitialiseSessionForRandomTestApp();
            var cipherOptHandle = await CipherOpt.NewPlaintextAsync();

            var seHandle = await IData.IData.NewSelfEncryptorAsync();

            await IData.IData.WriteToSelfEncryptorAsync(seHandle, data.ToList());

            var dataMapAddress = await IData.IData.CloseSelfEncryptorAsync(seHandle, cipherOptHandle);

            var seReaderHandle = await IData.IData.FetchSelfEncryptorAsync(dataMapAddress);

            var len = await IData.IData.SizeAsync(seReaderHandle);

            var readData = await IData.IData.ReadFromSelfEncryptorAsync(seReaderHandle, 0, len);

            Assert.AreEqual(data, readData);
        }