示例#1
0
        private void wrapUp(int outputSize)
        {
            byte[] encOut = XofUtilities.RightEncode(outputSize * 8);

            cshake.BlockUpdate(encOut, 0, encOut.Length);

            firstOutput = false;
        }
示例#2
0
        private static byte[] EncodeString(byte[] str)
        {
            if (Arrays.IsNullOrEmpty(str))
            {
                return(XofUtilities.LeftEncode(0L));
            }

            return(Arrays.Concatenate(XofUtilities.LeftEncode(str.Length * 8L), str));
        }
示例#3
0
        private byte[] encodeString(byte[] str)
        {
            if (str == null || str.Length == 0)
            {
                return(XofUtilities.LeftEncode(0));
            }

            return(Arrays.Concatenate(XofUtilities.LeftEncode(str.Length * 8L), str));
        }
示例#4
0
        public void Reset()
        {
            cshake.Reset();
            Arrays.Clear(buffer);

            byte[] hdr = XofUtilities.LeftEncode(B);
            cshake.BlockUpdate(hdr, 0, hdr.Length);

            nCount      = 0;
            bufOff      = 0;
            firstOutput = true;
        }
示例#5
0
 /// <summary>
 /// Base constructor
 /// </summary>
 /// <param name="bitLength">bit length of the underlying SHAKE function, 128 or 256.</param>
 /// <param name="N">the function name string, note this is reserved for use by NIST. Avoid using it if not required.</param>
 /// <param name="S">the customization string - available for local use.</param>
 public CShakeDigest(int bitLength, byte[] N, byte[] S) : base(bitLength)
 {
     if ((N == null || N.Length == 0) && (S == null || S.Length == 0))
     {
         diff = null;
     }
     else
     {
         diff = Arrays.ConcatenateAll(XofUtilities.LeftEncode(rate / 8), encodeString(N), encodeString(S));
         DiffPadAndAbsorb();
     }
 }
示例#6
0
        private void wrapUp(int outputSize)
        {
            if (bufOff != 0)
            {
                compress();
            }
            byte[] nOut   = XofUtilities.RightEncode(nCount);
            byte[] encOut = XofUtilities.RightEncode(outputSize * 8);

            cshake.BlockUpdate(nOut, 0, nOut.Length);
            cshake.BlockUpdate(encOut, 0, encOut.Length);

            firstOutput = false;
        }
示例#7
0
 public void BlockUpdate(byte[] inBuf, int inOff, int len)
 {
     byte[] bytes = XofUtilities.Encode(inBuf, inOff, len);
     cshake.BlockUpdate(bytes, 0, bytes.Length);
 }
示例#8
0
 public void Update(byte b)
 {
     byte[] bytes = XofUtilities.Encode(b);
     cshake.BlockUpdate(bytes, 0, bytes.Length);
 }