Exemplo n.º 1
0
 def _digest(self, space):
     with lltype.scoped_alloc(ropenssl.EVP_MD_CTX.TO) as ctx:
         with self.lock:
             ropenssl.EVP_MD_CTX_copy(ctx, self.ctx)
         digest_size = self.digest_size
         with rffi.scoped_alloc_buffer(digest_size) as buf:
             ropenssl.EVP_DigestFinal(ctx, buf.raw, None)
             ropenssl.EVP_MD_CTX_cleanup(ctx)
             return buf.str(digest_size)
Exemplo n.º 2
0
 def _digest(self, space):
     with lltype.scoped_alloc(ropenssl.EVP_MD_CTX.TO) as ctx:
         with self.lock:
             ropenssl.EVP_MD_CTX_copy(ctx, self.ctx)
         digest_size = self.digest_size
         with lltype.scoped_alloc(rffi.CCHARP.TO, digest_size) as digest:
             ropenssl.EVP_DigestFinal(ctx, digest, None)
             ropenssl.EVP_MD_CTX_cleanup(ctx)
             return rffi.charpsize2str(digest, digest_size)
Exemplo n.º 3
0
 def _digest(self, space):
     ctx = ropenssl.EVP_MD_CTX_new()
     if ctx is None:
         raise MemoryError
     try:
         with self.lock:
             if not ropenssl.EVP_MD_CTX_copy(ctx, self.ctx):
                 raise ValueError
         digest_size = self.digest_size
         with rffi.scoped_alloc_buffer(digest_size) as buf:
             ropenssl.EVP_DigestFinal(ctx, buf.raw, None)
             return buf.str(digest_size)
     finally:
         ropenssl.EVP_MD_CTX_free(ctx)