Questions tagged [php-openssl]

Using this extension, PHP can use some OpenSSL functions to do direct encryption. This tag should not be used for questions about encrypting traffic(HTTPS)

The OpenSSL extension for PHP uses the functions of (OpenSSL) for generation and verification of signatures and for doing full encryption and decryption of data. This module does not support the full suite of OpenSSL functions, but does offer access to actively maintained encryption libraries as opposed to deprecated libraries like .

For hashing (one-way encryption) check out

405 questions
2
votes
2 answers

Convert C# TripleDES ECB decrypt/encrypt into PHP with openssl_encrypt/openssl_decrypt

I'm trying to recreate the following C# implementation of TripleDES ECB with PKCS7 padding in PHP using openssl_encrypt and openssl_decrypt. private static string Key = ""; public…
Sobo Ta
  • 21
  • 4
2
votes
2 answers

Can we have multiple public keys with a single private key for OpenSSL ECC?

I'm using php OpenSSL in my project. How can I create multiple public keys using a single private key? In RSA we can't do such things. But how about ECC?
Mahdi
  • 187
  • 2
  • 14
2
votes
0 answers

Warning: openssl_sign() expects parameter 4 to be long

I'm trying to generate a JWT for using apple mapkit js. I found a open source code that generates the token which works fine on my local machine. However, I'm getting the following error when I uploaded to my server. Warning: openssl_sign() expects…
Julia
  • 1,207
  • 4
  • 29
  • 47
2
votes
1 answer

Encrypt and sign in Nodejs, validate signature in php

I would like to encrypt and sign certain data in nodejs and validate the signature in php. I keep on getting this error: error:04091077:rsa routines:int_rsa_verify:wrong signature length I have tried to change the algorithm being used, Also tried…
2
votes
1 answer

What is the right algorithm for digitally signing in C and veryfing in PHP?

I'm trying to digitally sign files/messages in C and verify the signature in PHP. I can verify it correctly in C, but when I try to import the signature and verify it in PHP it fails. I'm signing the message in C using this method: bool RSASign(…
Nelson Teixeira
  • 6,297
  • 5
  • 36
  • 73
2
votes
1 answer

openssl_encrypt with a IV of 0xFFFFFFFFFFFFFFFF with encryption mode bf-cbc

I'm using a third party software, that creates key in blowfish in encryption mode CBC and an IV of 0xFFFFFFFFFFFFFFFF. How can I pass an IV like this to openssl_encrypt? The encoding of the source string is windows 1252. Im using PHP 7.3 with…
SuperNova
  • 2,792
  • 2
  • 25
  • 34
2
votes
1 answer

How to get SSL Certificate Hash Algorithm OID using php's openssl_x509_parse

I am using php's OpenSSL Functions ( openssl_x509_parse ) to parse SSL certificate info of given site. Sample Code: $stream = stream_context_create( array( "ssl" => array( "allow_self_signed" => true, …
Umair Khan
  • 1,684
  • 18
  • 34
2
votes
0 answers

Rewrite code from php to node js (php openssl_encrypt)

PHP function encodeBase64Url($data) { return strtr(base64_encode($data), ['+' => '-', '/' => '_', '=' => '']); } function encrypt($data, $secret) { $data = json_encode($data); $salt = openssl_random_pseudo_bytes(16); $data =…
2
votes
2 answers

How to use openSSL in command line to encrypt HEX FILE or HEX representation of plaintext?

I am using OpenSSL in command line to encrypt plaintext using aes encryption. Following command is used to encrypt the plaintext and produces the ciphertext. openssl enc -aes-128-ecb -in plaintext_in_char.txt -out plaintext_in_char.txt.enc -K…
bholanath
  • 1,699
  • 1
  • 22
  • 40
2
votes
0 answers

OpenSSL text max size?

Using OpenSSL I have created a basic encrypt/decrypt class. My goal is to encrypt text (JSON) to be sent over http to/from a remote web_service. (yeah, I know I could use https instead, but there're some technical constraints not to use it in this…
MarcM
  • 2,173
  • 22
  • 32
2
votes
1 answer

symmetric AES encryption with php produces different result than openssl cmd

I need to make a simple very basic encryption with AES 128 ECB mode. The idea is to generate a cryptogram, code it in base64 and then decipher that text from a web service in php to process its content. Later we will increase the robustness of the…
Sergio Sánchez Sánchez
  • 1,694
  • 3
  • 28
  • 48
2
votes
1 answer

Decrypt AES-256-CFB in PHP with openssl instead mcrypt

The function below correctly decrypt the data in php5 function decrypt_mcrypt($key, $str) { $str = base64_decode($str); $iv = substr($str, 0, 16); $str = substr($str, 16); return mcrypt_decrypt(MCRYPT_RIJNDAEL_128, $key, $str,…
vaal
  • 153
  • 3
  • 8
2
votes
1 answer

Rijndael 192-bit block size mcrypt alternative

Please read this question before knee-jerking it as a duplicate (although if it actually is, not sure why I couldn't find it, but GREAT!!) We have been using mcrypt with the rijndael-192 module in cfb mode for years now. We have a LOT of stuff…
superphonic
  • 7,954
  • 6
  • 30
  • 63
2
votes
1 answer

SSL3_GET_SERVER_CERTIFICATE certificate verify failed on Windows 10 Pro with IIS

When trying to send emails through smtp.google.com via PHPMailer on PHP hosted by IIS on Windows 10, I get this error message: Connection failed. Error #2: stream_socket_enable_crypto(): SSL operation failed with code 1. OpenSSL Error…
HerrimanCoder
  • 6,835
  • 24
  • 78
  • 158
2
votes
1 answer

Issue decrypting Alexa request signature using openssl_public_decrypt

I'm implementing a validator for validating incoming requests from Amazon Alexa. I'm on step 5 and 6 which state: 5) base64-decode the Signature header value on the request to obtain the encrypted signature. 6) Use the public key extracted from…
craig_h
  • 31,871
  • 6
  • 59
  • 68