BraintreeEncryption.Library.BouncyCastle.Crypto.Engines.RsaCoreEngine.ConvertOutput C# (CSharp) Method

ConvertOutput() public method

public ConvertOutput ( BigInteger result ) : byte[]
result BraintreeEncryption.Library.BouncyCastle.Math.BigInteger
return byte[]
        public byte[] ConvertOutput(
			BigInteger result)
        {
            byte[] output = result.ToByteArrayUnsigned();

            if (forEncryption)
            {
                int outSize = GetOutputBlockSize();

                // TODO To avoid this, create version of BigInteger.ToByteArray that
                // writes to an existing array
                if (output.Length < outSize) // have ended up with less bytes than normal, lengthen
                {
                    byte[] tmp = new byte[outSize];
                    output.CopyTo(tmp, tmp.Length - output.Length);
                    output = tmp;
                }
            }

            return output;
        }

Usage Example

コード例 #1
0
        /**
         * Process a single block using the basic RSA algorithm.
         *
         * @param inBuf the input array.
         * @param inOff the offset into the input buffer where the data starts.
         * @param inLen the length of the data to be processed.
         * @return the result of the RSA process.
         * @exception DataLengthException the input block is too large.
         */
        public byte[] ProcessBlock(
            byte[]      inBuf,
            int inOff,
            int inLen)
        {
            if (core == null)
            {
                throw new InvalidOperationException("RSA engine not initialised");
            }

            return(core.ConvertOutput(core.ProcessBlock(core.ConvertInput(inBuf, inOff, inLen))));
        }