php-openssl

Openssl equivalent to mcrypt_get_block_size

两盒软妹~` 提交于 2019-12-11 00:55:09
问题 I am currently in the process of replacing Mcrypt with OpenSSL since Mcrypt will be deprecated in PHP 7.1. I need is a way to get the blocksize per algorithm like mcrypt_get_block_size(). I am wondering if there is an equivalent function to mcrypt_get_block_size() but it's pretty badly documented can't seem to find it. 回答1: php-openssl unfortunately doesn't have an API that would give you the cipher blockSize. If you really need it, you'd have to hard-code the blockSize (per algorithm).

Translate Windows RC4 CryptDeriveKey to PHP for openssl

半城伤御伤魂 提交于 2019-12-07 23:37:10
问题 This is the second component of the legacy system translation we’ve been trying to do. We have managed to match exactly the initial binary password/key that Windows ::CryptHashData generates. That password/key is passed to ::CryptDeriveKey where it performs a number of steps to create the final key to be used by ::CryptEncrypt. My research has led me to the CryptDeriveKey documentation where it clearly describes the steps required to derive the key for ::CryptEncrypt but so far I haven’t been

openssl_encrypt returns false

感情迁移 提交于 2019-12-07 14:26:43
问题 I am trying to encrypt a string using openssl_encrypt in PHP but it keeps returning FALSE. $encrypted = openssl_encrypt('1234', 'AES-256-CBC', 'kGJeGF2hEQ', OPENSSL_ZERO_PADDING, '1234123412341234'); What am I doing wrong? 回答1: On top of answers posted, which are excellent, the code you're after, given your input parameters would be the following: $plaintext = '1234'; $cipher = 'AES-256-CBC'; $key = 'this is a bad key'; $iv = openssl_random_pseudo_bytes(openssl_cipher_iv_length($cipher));

How to verify CA using PHP's OpenSSL extension?

浪尽此生 提交于 2019-12-07 07:43:14
问题 In the command line, I can verify that certificate is issued by trusted CA by typing openssl verify mycert.pem How do I do same with PHP's OpenSSL library? PHP has an openssl_verify function which takes many extra parameters: data , string $signature , mixed $pub_key_id How do I repeat that simple command line operation with corresponding PHP function? 回答1: This is pretty easy with phpseclib, a pure PHP X509 implementation. eg. <?php include('File/X509.php'); $x509 = new File_X509(); $x509-

openssl_encrypt returns false

六眼飞鱼酱① 提交于 2019-12-05 21:42:14
I am trying to encrypt a string using openssl_encrypt in PHP but it keeps returning FALSE. $encrypted = openssl_encrypt('1234', 'AES-256-CBC', 'kGJeGF2hEQ', OPENSSL_ZERO_PADDING, '1234123412341234'); What am I doing wrong? Mjh On top of answers posted, which are excellent, the code you're after, given your input parameters would be the following: $plaintext = '1234'; $cipher = 'AES-256-CBC'; $key = 'this is a bad key'; $iv = openssl_random_pseudo_bytes(openssl_cipher_iv_length($cipher)); $encrypted = openssl_encrypt($plaintext, $cipher, $key, 0, $iv); if(false === $encrypted) { echo openssl

How to verify CA using PHP's OpenSSL extension?

吃可爱长大的小学妹 提交于 2019-12-05 17:57:52
In the command line, I can verify that certificate is issued by trusted CA by typing openssl verify mycert.pem How do I do same with PHP's OpenSSL library? PHP has an openssl_verify function which takes many extra parameters: data , string $signature , mixed $pub_key_id How do I repeat that simple command line operation with corresponding PHP function? This is pretty easy with phpseclib, a pure PHP X509 implementation . eg. <?php include('File/X509.php'); $x509 = new File_X509(); $x509->loadCA('...'); $x509->loadX509('...'); echo $x509->validateSignature() ? 'valid' : 'invalid'; ?> See http:/

Issue decrypting Alexa request signature using openssl_public_decrypt

|▌冷眼眸甩不掉的悲伤 提交于 2019-12-04 18:42:33
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 the signing certificate to decrypt the encrypted signature to produce the asserted hash value. I've managed to extract the public key from the PEM-encoded X.509 certificate by doing: $publicKey = openssl_pkey_get_public($pem); $keyData = openssl_pkey_get_details($publicKey); Which returns my public key. I've then attempted to decrypt the signature like

How to upgrade openssl 0.9.8 to 1.0.2 with mod_ssl in Apache 2.2.9

血红的双手。 提交于 2019-12-04 17:36:56
I am asked to recompile mo_ssl with openssl 1.0.2 in SuseSE11SP3. However, I am a newbie to Suse, but know a little bit of linux. OS : Suse SE11SP3 Openssl : 0.9.8j <-which comes with original Suse linux Web Server : Apache httpd 2.2.9 Here is limitation I have. I cannot use zypper or rpm because company security policy does not allow me to do it. It is absurd, this is how it goes here. Another limitation I have is this system is used by other web servers which I don't have permission. I have to make it as locally as possible. What I want it to happen is that when I recompile apache server, I

Implementing secp256k1 (ECDSA) in PHP (for Bitcoin) [closed]

前提是你 提交于 2019-12-04 12:16:01
问题 Closed. This question is off-topic. It is not currently accepting answers. Want to improve this question? Update the question so it's on-topic for Stack Overflow. Closed 6 years ago . To keen downvoters and/or closers: If you think this is offtopic for SO, kindly point me out other StackExchange site where this question would be more appropriate. How to implement ECDSA curve secp256k1 in PHP? Or rather: Are there any solutions - ie. includable specialized classes - already done? I can see

Native PHP 5.6 OpenSSL Composer.phar failed to enable crypto on Windows

守給你的承諾、 提交于 2019-12-04 05:51:38
问题 I have a problem with PHP 5.6 native on a Windows machine. I get this error when I try to run a composer update (php composer.phar update): [Composer\Downloader\TransportException] The "https://packagist.org/packages.json" file could not be downloaded: SSL operation failed with code 1. OpenSSL Error messages: error:140770FC:SSL routines:SSL23_GET_SERVER_HELLO:unknown protocol Failed to enable crypto failed to open stream: operation failed The openssl extension is loaded. I already downloaded