Ejemplo n.º 1
0
 def __init__(self, algorithm):
     if algorithm not in _ALGORITHMS:
         raise ValueError('unknown algorithm', algorithm)
     size = C.passacre_gen_size()
     self._algorithm = algorithm
     self._buf = ffi.new('unsigned char []', size)
     self._context = ffi.cast('struct passacre_gen_state *', self._buf)
     self._check(C.passacre_gen_init, _ALGORITHMS[algorithm])
Ejemplo n.º 2
0
 def __init__(self, algorithm):
     if algorithm not in _ALGORITHMS:
         raise ValueError('unknown algorithm', algorithm)
     size = C.passacre_gen_size()
     self._algorithm = algorithm
     self._buf = ffi.new('unsigned char []', size)
     self._context = ffi.cast('struct passacre_gen_state *', self._buf)
     self._check(C.passacre_gen_init, _ALGORITHMS[algorithm])
Ejemplo n.º 3
0
 def squeeze(self, n_bytes):
     output = ffi.new('unsigned char[]', n_bytes)
     self._check(C.passacre_gen_squeeze, output, n_bytes)
     return ffi.buffer(output)[:]
Ejemplo n.º 4
0
 def squeeze(self, n_bytes):
     output = ffi.new('unsigned char[]', n_bytes)
     self._check(C.passacre_gen_squeeze, output, n_bytes)
     return ffi.buffer(output)[:]