public static int CryptoOnetimeauthVerify(byte[] H, int Hoffset, byte[] Inv, int Invoffset, long Inlen, byte[] K) { byte[] correct = new byte[16]; Poly1305.CryptoOnetimeauth(correct, 0, Inv, Invoffset, Inlen, K); return(Verify16.CryptoVerify(H, Hoffset, correct)); }
public static int CryptoSecretbox(byte[] C, byte[] M, long Mlen, byte[] N, byte[] K) { if (Mlen < 32) { return(-1); } Xsalsa20.CryptoStreamXor(C, M, Mlen, N, K); Poly1305.CryptoOnetimeauth(C, 16, C, 32, Mlen - 32, C); for (int i = 0; i < 16; ++i) { C[i] = 0; } return(0); }