Search the Community
Showing results for tags 'rsa'.
-
I need to send a password that's RSA encrypted with a public key (along with some other data). Here are the exact instructions from the documentation for the password: Encode password in Base64 and ensure UTF-8 encoding Encrypt password with RSA with provided public key, no block mode, and PKCS1Padding Encode resulting encryption in Base64 with ensured UTF-8 encoding Here's the code I'm using that to me seems correct: function encryptPassword($pass) { $pass = base64_encode($pass); $fp = fopen("./cert.crt", "r"); $publicKey = fread($fp, 8192); fclose($fp); openssl_get_publickey($publicKey); openssl_public_encrypt($pass, $cryptedText, $publicKey, OPENSSL_PKCS1_PADDING); return base64_encode(utf8_encode($cryptedText)); } I'm getting an error on the other side saying the password can't be decoded. Support from them is basically non-existent other than the error message, and them saying everything is correct on their side. My question is, am I sending what they're asking for according to the documentation? Thanks in advance!
-
Hello All, I am working on a project where the client has provided me with the public key file and the private-key is being passed via url, along with 2 params that will be used on my end. These are the basics of the process that I am to use for verifying. Generate your own plaintext message matching the format of the string provided Create a SHA1withRSA hash of this message using the provided public key (UTF-16LE encode and pass this value) Base64 decode the signature Using a SHA1withRSA validator, verify your hashed message matches the Base64 decoded value in step 3 At this point I have performed steps 1-3 but am having an issue with step 4. The code is failing here. When I say failing I mean it is not being verified. $base64Sig = base64_decode($signature, true); $publickey = getPemKey(); $rsa = new Crypt_RSA(); $rsa->loadKey($publickey, CRYPT_RSA_PUBLIC_FORMAT_RAW); $hashedPlainText = sha1($utfString); $utfString = mb_convert_encoding($hashedPlainText ,"UTF-16LE"); echo $rsa->verify($hashedPlainText, $base64Sig) ? 'verified' : 'unverified'; If anyone can provide me with a basic example or a few sites that have examples with example data, it would be appreciated as I'm not sure I am "Using a SHA1withRSA validator". Thanks ahead of time!
- 7 replies
-
- rsa
- encryption
-
(and 2 more)
Tagged with: