示例#1
0
        public byte[] DefaultEncrypt(byte[] plaintextBytes, KeyMaterial64 keyMaterial64)
        {
            var binaryEncryptResponse = BinaryEncrypt(new Clearbytes(plaintextBytes), keyMaterial64, new RoundsExponent(RoundsExponent.DontMakeRounds), null);

            if (binaryEncryptResponse.IsSuccess)
            {
                return(XDSSecFormatter.CreateBinary(binaryEncryptResponse.Result));
            }
            throw new Exception(binaryEncryptResponse.Error);
        }
示例#2
0
        public byte[] DefaultDecrypt(byte[] cipherTextBytes, KeyMaterial64 keyMaterial64, LongRunningOperationContext context = null)
        {
            CipherV2 cipherV2 = XDSSecFormatter.DissectXDSSecBytes(cipherTextBytes, context);
            var      binaryDecryptResponse = BinaryDecrypt(cipherV2, keyMaterial64, context);

            if (!binaryDecryptResponse.IsSuccess)
            {
                throw new Exception(binaryDecryptResponse.Error);
            }
            return(binaryDecryptResponse.Result.GetBytes());
        }
示例#3
0
        public Response <CipherV2> BinaryDecodeXDSSec(byte[] xdsSecBytes, LongRunningOperationContext context)
        {
            var response = new Response <CipherV2>();

            try
            {
                Guard.NotNull(xdsSecBytes);
                EnsurePlatform();
                context?.CancellationToken.ThrowIfCancellationRequested();
                response.Result = XDSSecFormatter.DissectXDSSecBytes(xdsSecBytes, context);
                response.SetSuccess();
            }
            catch (Exception e)
            {
                response.SetError(e);
            }
            return(response);
        }
示例#4
0
        public Response <byte[]> BinaryEncodeXDSSec(CipherV2 cipherV2, LongRunningOperationContext context)
        {
            var response = new Response <byte[]>();

            try
            {
                Guard.NotNull(cipherV2);
                EnsurePlatform();
                context?.CancellationToken.ThrowIfCancellationRequested();
                response.Result = XDSSecFormatter.CreateBinary(cipherV2);
                response.SetSuccess();
            }
            catch (Exception e)
            {
                response.SetError(e);
            }
            return(response);
        }
示例#5
0
        public Response <CipherV2> DecodeXDSSec(string xdsSecText, LongRunningOperationContext context)  // should the parameter type be XDSSecText?
        {
            var response = new Response <CipherV2>();

            try
            {
                Guard.NotNull(xdsSecText);
                EnsurePlatform();

                response.Result = XDSSecFormatter.DissectXDSSecText(xdsSecText, context);
                response.SetSuccess();
            }
            catch (Exception e)
            {
                response.SetError(e);
            }
            return(response);
        }
示例#6
0
        public Response <XDSSecText> EncodeXDSSec(CipherV2 cipherV2)
        {
            var response = new Response <XDSSecText>();

            try
            {
                Guard.NotNull(cipherV2);
                EnsurePlatform();

                response.Result = XDSSecFormatter.CreateXDSSecText(cipherV2);
                response.SetSuccess();
            }
            catch (Exception e)
            {
                response.SetError(e);
            }
            return(response);
        }