PKI verification across Java and Python -


I am trying to implement a PKI verification plan, where a message is signed on the string server with the private key , The signature is stored on the client with the message string. The client then verifies the signature using the public key.

There are restrictions on my environment, the server is Google App Engine and the client is Java program. I have played with Java only-and python-only solutions of PKI validation and went to work them, but While taking an action in Python and causing another issue in Java, mainly because of my understanding of key file format restrictions and cryptography vocabulary.

Crypto support in GE is one of the biggest limitations. The only supported library is PyCrypto and this library can not read public / private keys stored in PEM, DER or X509 formats. As far as I know, only MCCRPT supports reading from these files, but it can not be used inside GAE because it is a wrapper around OpenSL, so there is no pure Python solution even If I can get a way to translate public / private keys from PEM / DER / X509, then it will work for me in a format that understands the picture format. But I could not find any way to do this. Any thoughts there?

I could read a private key from the Tlslite PEM file and get the signature as a possible solution tlslite and could create a signature. Here's the code.

  import tlslite.utils.keyfactory parsePEMKey S = open ('private.pem') from tlslite.utils.cryptomath bytesToBase64 import. Read () key = parsePEMKey (s) doc = 'sample text' bytes = array ('b') bytes.fromstring (doc) print bytesToBase64 (key.sign (byte))  

The corresponding Java code I used to verify is the signature.

  string signAlgo = "SHA1WithRSAEncryption"; // public.der byte [] encodedkey = new byte [294] read public key; // Shortcut Hardcoding GetAssets () Open ("public.der"). Read (encoded); // Create Public Key Object X509EncodedKeySpec publicKeySpec = New X509EncodedKeySpec (Encoded); Keyfiler kf = keyfactor.just instance ("RSA"); PublicKey pk = kf.generatePublic (publicKeySpec); // read signature (created by above Python code) Byte [] encoded SIG = new byte [345]; .. GetAssets () open ("signature.txt") read (encodedSig); Byte [] Decoded CIG = Base 64.decodeBase64 (Encoded SIG); // Verification Verification Signalg = Signature.getInstance (signAlgo); Verifyalg.initVerify (P); Verifyalg.update (message.getBytes ()); Log D. (Tag, "virif:" + verifiedGraphification (decodedcig));  

Verification ends.

I suspect that if TLSLite is using different algorithms for signing signature than expected of Java code.

So I tried out to find that.

SHA1

On the Java side, I try to find out all supported algorithms with this code:

  set & lt; String & gt; Algos = java.security.Security.getAlgorithms ("Signature"); For (string algo: algos) {log d. (Tag, apart); }  

This is the reason why given me

  MD4WithRSAEncryption RSASSA-PSS SHA1withDSA SHA1withRSA / ISO9796-2 1.2.840.113549.1.1.10 SHA512withRSA / PSS MD5withRSA / ISO9796-2 DSA SHA512WithRSAEncryption SHA224withRSA / PSS NONIVITHDSA SHA256withRSA / PSS SHA224WithRSAEncryption SHA256WithRSAEncryption SHA1withRSA / PSS SHA1WithRSAEncryption SHA384withRSA / Pisss SHA384WithRSAEncryption MD5WithRSAEncryption  

I tried all SHA1 values ​​on the Java side but none Pielsis 1- The SHA 1A helps verify the signature prepared by TLSLite with the Loos. Any ideas about this mapping?

These are different operations in Python, you have hash and sign Need to use. The default SHA1 hash must be.


Comments

Popular posts from this blog

c# - How to capture HTTP packet with SharpPcap -

php - Multiple Select with Explode: only returns the word "Array" -

php - jQuery AJAX Post not working -