PHP's openssl_sign() using M2Crypto?

heikki at heikki at
Mon May 22 19:30:25 CEST 2006

KW wrote:
> The openssl module in PHP basicly does this (C code):
>   EVP_SignInit(&md_ctx, EVP_sha1());
>   EVP_SignUpdate(&md_ctx, data, data_len);
>   EVP_SignFinal(&md_ctx, sigbuf, &siglen, pkey);
> Looks like some magic is used to get pkey, I think that's what I'm missing.
> See php_openssl_evp_from_zval() in PHP's ext/openssl/openssl.c.
> I've tried the following:
>   key = M2Crypto.EVP.load_key(keyfile, lambda x: passphr)
>   hmac = M2Crypto.EVP.HMAC(key, 'sha1')
>   hmac.update(message)

Does this work?:

key = M2Crypto.EVP.load_key(keyfile, lambda x: passphr)
signature =

> Unfortunately M2Crypto documentation is practically nonexistent..

A lot of the OpenSSL documentation works fine, the names are usually
straight mapping.

More information about the Python-list mailing list