Esempio n. 1
0
        public virtual byte[] Sm2GetZ(byte[] userId, ECPoint userKey)
        {
            Sm3Digest sM3Digest = new Sm3Digest();
            int       num       = userId.Length * 8;

            sM3Digest.Update((byte)((num >> 8) & 0xFF));
            sM3Digest.Update((byte)(num & 0xFF));
            sM3Digest.BlockUpdate(userId, 0, userId.Length);
            byte[] array = EccA.ToByteArray();
            sM3Digest.BlockUpdate(array, 0, array.Length);
            array = EccB.ToByteArray();
            sM3Digest.BlockUpdate(array, 0, array.Length);
            array = EccGx.ToByteArray();
            sM3Digest.BlockUpdate(array, 0, array.Length);
            array = EccGy.ToByteArray();
            sM3Digest.BlockUpdate(array, 0, array.Length);
            array = userKey.AffineXCoord.ToBigInteger().ToByteArray();
            sM3Digest.BlockUpdate(array, 0, array.Length);
            array = userKey.AffineYCoord.ToBigInteger().ToByteArray();
            sM3Digest.BlockUpdate(array, 0, array.Length);
            byte[] array2 = new byte[sM3Digest.GetDigestSize()];
            sM3Digest.DoFinal(array2, 0);
            return(array2);
        }
Esempio n. 2
0
 public Sm3Digest(Sm3Digest t) : base(t)
 {
     Array.Copy(X, 0, X, 0, X.Length);
     _offset = t._offset;
     Array.Copy(t._v, 0, _v, 0, t._v.Length);
 }