示例#1
0
def secretbox_xsalsa20poly1305_open(c, n, k):
    if len(c) < 16: raise ValueError('Too short for XSalsa20Poly1305 box')
    s = stream_xsalsa20(32, n, k)
    if not onetimeauth_poly1305_verify(c[:16], c[16:], s):
        raise ValueError('Bad authenticator for XSalsa20Poly1305 box')
    s = stream_xsalsa20(16 + len(c), n, k)
    return xor(c[16:], s[32:])
示例#2
0
def secretbox_xsalsa20poly1305_open(c, n, k):
  if len(c) < 16: raise ValueError('Too short for XSalsa20Poly1305 box')
  s = stream_xsalsa20(32, n, k)
  if not onetimeauth_poly1305_verify(c[:16], c[16:], s):
    raise ValueError('Bad authenticator for XSalsa20Poly1305 box')
  s = stream_xsalsa20(16 + len(c), n, k)
  return xor(c[16:], s[32:])
示例#3
0
def secretbox_xsalsa20poly1305(m, n, k):
    s = stream_xsalsa20(32 + len(m), n, k)
    c = xor(m, s[32:])
    a = onetimeauth_poly1305(c, s[:32])
    return a + c
示例#4
0
def secretbox_xsalsa20poly1305(m, n, k):
  s = stream_xsalsa20(32 + len(m), n, k)
  c = xor(m, s[32:])
  a = onetimeauth_poly1305(c, s[:32])
  return a + c