m2crypto

Problem with M2Crypto's AES

混江龙づ霸主 提交于 2019-12-02 09:49:47
问题 Can someone please point out mistakes in this code: __author__="gaurav" __date__ ="$15 Feb, 2011 5:10:59 PM$" import M2Crypto from base64 import b64encode, b64decode ENC=1 DEC=0 def AES_build_cipher(key, iv, op=ENC): """""""" return M2Crypto.EVP.Cipher(alg='aes_128_cbc', key=key, iv=iv, op=op) def AES_encryptor(key,msg, iv=None): """""" #Decode the key and iv key = b64decode(key) if iv is None: iv = '\0' * 16 else: iv = b64decode(iv) # Return the encryption function def encrypt(data): cipher

Problem with M2Crypto's AES

情到浓时终转凉″ 提交于 2019-12-02 04:14:26
Can someone please point out mistakes in this code: __author__="gaurav" __date__ ="$15 Feb, 2011 5:10:59 PM$" import M2Crypto from base64 import b64encode, b64decode ENC=1 DEC=0 def AES_build_cipher(key, iv, op=ENC): """""""" return M2Crypto.EVP.Cipher(alg='aes_128_cbc', key=key, iv=iv, op=op) def AES_encryptor(key,msg, iv=None): """""" #Decode the key and iv key = b64decode(key) if iv is None: iv = '\0' * 16 else: iv = b64decode(iv) # Return the encryption function def encrypt(data): cipher = AES_build_cipher(key, iv, ENC) v = cipher.update(data) v = v + cipher.final() del cipher v =

M2Crypto - import keys from non-standard file?

跟風遠走 提交于 2019-12-01 12:02:06
问题 I have a file with the public exponent and modulus in it. They're not in pem or xml or der format, they're just the values written in at their offsets. How can I make a public key out of them with M2Crypto? I also have the private key in the same format. I've managed to use code that someone posted here on Stackoverflow to generate a PEM file with php, but this seems like an extremely ridiculous way to do it. This isn't a one-time thing either, I need to be able to read the public exponent

M2Crypto - import keys from non-standard file?

你说的曾经没有我的故事 提交于 2019-12-01 11:50:29
I have a file with the public exponent and modulus in it. They're not in pem or xml or der format, they're just the values written in at their offsets. How can I make a public key out of them with M2Crypto? I also have the private key in the same format. I've managed to use code that someone posted here on Stackoverflow to generate a PEM file with php, but this seems like an extremely ridiculous way to do it. This isn't a one-time thing either, I need to be able to read the public exponent and modulus from files in this format to check the signature. mowwwalker Thank you very much to Lars here

M2Crypto RSA.sign vs OpenSSL rsautl -sign

只愿长相守 提交于 2019-12-01 08:58:48
问题 M2Crypto and OpenSSL CLI doesn't seem to create the same digital signature. Here is the code that I use in Python: import M2Crypto rsa = M2Crypto.RSA.load_key("privkey.pem") open("sig_m2crypto", "w").write(rsa.sign("md5-digest", "md5")) Here is the command line with OpenSSL: echo "md5-digest" | openssl rsautl -sign -inkey privkey.pem > sig_openssl With the same input, the result of sig_m2crypto and sig_openssl are always different. The significance would be I can not verify signatures

Need help using M2Crypto.Engine to access USB Token

空扰寡人 提交于 2019-12-01 00:57:35
I am using M2Crypto-0.20.2. I want to use engine_pkcs11 from the OpenSC project and the Aladdin PKI client for token based authentication making xmlrpc calls over ssl. from M2Crypto import Engine Engine.load_dynamic() dynamic = Engine.Engine('dynamic') # Load the engine_pkcs from the OpenSC project dynamic.ctrl_cmd_string("SO_PATH", "/usr/local/ssl/lib/engines/engine_pkcs11.so") Engine.cleanup() Engine.load_dynamic() # Load the Aladdin PKI Client aladdin = Engine.Engine('dynamic') aladdin.ctrl_cmd_string("SO_PATH", "/usr/lib/libeTPkcs11.so") key = aladdin.load_private_key("PIN","password")

swig unable to find openssl conf

僤鯓⒐⒋嵵緔 提交于 2019-11-30 16:24:29
问题 Trying to install m2crypto and getting these errors, can anyone help ? SWIG/_evp.i:12: Error: Unable to find 'openssl/opensslconf.h' SWIG/_ec.i:7: Error: Unable to find 'openssl/opensslconf.h' 回答1: ln -s /usr/include/x86_64-linux-gnu/openssl/opensslconf.h /usr/include/openssl/opensslconf.h Just made this and everything worked fine. 回答2: Installing libssl-dev (which contains development libraries, header files) will solve the issue. sudo apt-get install libssl-dev 回答3: This was a bug in

Sign CSR from client using CA root certificate in python

▼魔方 西西 提交于 2019-11-30 09:13:32
I am new to python and still learning it so my question can be little naive. Please bear with it ;) The problem is client will be sending CSR and I want to sign it with my CA root certificate and return the signed certificate back to client. I have been using this command to do it using command line openssl x509 -req -in device.csr -CA root.pem -CAkey root.key -CAcreateserial -out device.crt -days 500 same thing I want achieve using python. I have come across python library for openssl pyopenssl is it possible using this library ? How ? or shoudl I go for M2Crypto ? You can indeed go with

Trouble installing m2crypto with pip on OS X / macOS

给你一囗甜甜゛ 提交于 2019-11-29 18:57:07
pip install m2crypto Generates the following output: building 'M2Crypto.__m2crypto' extension swigging SWIG/_m2crypto.i to SWIG/_m2crypto_wrap.c swig -python -I/System/Library/Frameworks/Python.framework/Versions/2.7/include/python2.7 -I/usr/include -I/usr/include/openssl -includeall -modern -o SWIG/_m2crypto_wrap.c SWIG/_m2crypto.i SWIG/_m2crypto.i:30: Error: Unable to find 'openssl/opensslv.h' SWIG/_m2crypto.i:33: Error: Unable to find 'openssl/safestack.h' SWIG/_evp.i:12: Error: Unable to find 'openssl/opensslconf.h' SWIG/_ec.i:7: Error: Unable to find 'openssl/opensslconf.h' error: command

Pass connected SSL Socket to another Process

旧街凉风 提交于 2019-11-29 17:04:04
I am struggling to find a mechanism to send a request to the target server and when the socket has data to be read, pass the socket to another process for getting the data out. I came so far using epoll on Linux, to implement it to the point that i do the handshake, i send the request and the request arrives, then i pass the socket fd to another process for futher handling, i explicitly save the SSL Session using PEM_write_bio_SSL_SESSION and then read it using PEM_read_bio_SSL_SESSION and add it to the context but i can not read the ssl socket in another process because i get either Internal