Commits

Adam Pritchard committed edac2fe

Ensure that private key password is handled as a string (unicode stuff causes errors)

Comments (0)

Files changed (1)

Automation/psi_ops_crypto_tools.py

     rsa_key = M2Crypto.RSA.gen_key(RSA_KEY_LENGTH_BITS, RSA_EXPONENT)
     buffer = M2Crypto.BIO.MemoryBuffer()
     assert(1 == rsa_key.save_key_bio(
-                    buffer, callback=lambda _: private_key_password))
+                    buffer, callback=lambda _: str(private_key_password)))
     return buffer.read_all()
 
 
 def get_base64_der_public_key(key_pair, private_key_password):
     rsa_key = M2Crypto.RSA.load_key_string(
-                key_pair, callback=lambda _: private_key_password)
+                key_pair, callback=lambda _: str(private_key_password))
     buffer = M2Crypto.BIO.MemoryBuffer()
     assert(1 == rsa_key.save_pub_key_bio(buffer))
     pem = buffer.read_all()
     public_key_digest = sha.digest()
 
     rsa_key = M2Crypto.RSA.load_key_string(
-                key_pair, callback=lambda _: private_key_password)
+                key_pair, callback=lambda _: str(private_key_password))
     signature = rsa_key.sign(data_digest, algo='sha256')
 
     return json.dumps(