Example #1
0
def secretbox_salsa20hmacsha512_open(c, n, k):
  if len(c) < 32: raise ValueError('Too short for Salsa20HMACSHA512 box')
  s = stream_salsa20(32, n, k)
  if not auth_hmacsha512_verify(c[:32], c[32:], s):
    raise ValueError('Bad authenticator for Salsa20HMACSHA512 box')
  s = stream_salsa20(len(c), n, k)
  return xor(c[32:], s[32:])
Example #2
0
def secretbox_salsa20hmacsha512_open(c, n, k):
  if len(c) < 32: raise ValueError('Too short for Salsa20HMACSHA512 box')
  s = stream_salsa20(32, n, k)
  if not auth_hmacsha512_verify(c[:32], c[32:], s):
    raise ValueError('Bad authenticator for Salsa20HMACSHA512 box')
  s = stream_salsa20(len(c), n, k)
  return xor(c[32:], s[32:])
Example #3
0
def secretbox_salsa20hmacsha512(m, n, k):
    s = stream_salsa20(len(m) + 32, n, k)
    c = xor(m, s[32:])
    a = auth_hmacsha512(c, s[:32])
    return a + c
Example #4
0
def secretbox_salsa20hmacsha512(m, n, k):
  s = stream_salsa20(len(m) + 32, n, k)
  c = xor(m, s[32:])
  a = auth_hmacsha512(c, s[:32])
  return a + c