pkcs#7

Encryption using PKCS#7

妖精的绣舞 提交于 2019-12-01 12:45:19
问题 I am using Bouncy Castle provided library to encrypt,decrypt,sign and verify sign. I am doing this as 1. Encrypt data 2. Sign data 3. Write signed byte to a file 4. Read signed byte from file 5. Verify signature 6. Decrypt data I have taken reference from Beginning Cryptography with Java My problem is in step 5 when i am verifying data i am getting org.bouncycastle.cms.CMSException: message-digest attribute value does not match calculated value My code is below import java.io

Warning: openssl_pkcs7_sign(): error getting private key using WAMP

浪尽此生 提交于 2019-12-01 06:29:17
I am trying to sign PDF using TCPDF, but I have got this error: Warning: openssl_pkcs7_sign(): error getting private key in C:\wamp\www\tcpdf\tcpdf.php on line 7594. My PHP version is 5.5.12 and TCPDF 6.2.11. Windows 7. Other examples run well but this fails. I have tried: 'file://'.( dirname(FILE)).'./path/to/file' and again $certificate = 'file://'.realpath('../tcpdf.crt'); but does not work for me. I think file:// is not correct. You fetch die real path with dirname(__FILE__) that should be enough. So i prefer: $certificate = __DIR__'/../tcpdf.crt'; __DIR__ or dirname(FILE) is the path to

Warning: openssl_pkcs7_sign(): error getting private key using WAMP

≡放荡痞女 提交于 2019-12-01 04:27:38
问题 I am trying to sign PDF using TCPDF, but I have got this error: Warning: openssl_pkcs7_sign(): error getting private key in C:\wamp\www\tcpdf\tcpdf.php on line 7594. My PHP version is 5.5.12 and TCPDF 6.2.11. Windows 7. Other examples run well but this fails. I have tried: 'file://'.( dirname(FILE)).'./path/to/file' and again $certificate = 'file://'.realpath('../tcpdf.crt'); but does not work for me. 回答1: I think file:// is not correct. You fetch die real path with dirname(__FILE__) that

Warning: openssl_pkcs7_sign() [function.openssl-pkcs7-sign]: error getting private key in C:\\xampp\\htdocs\\this\\tcpdf\\tcpdf.php on line 8366

こ雲淡風輕ζ 提交于 2019-12-01 03:58:50
I am using TCPDF to sign PDF, but when running the example 52 I got this error: Warning: openssl_pkcs7_sign() [function.openssl-pkcs7-sign]: error getting private key in C:\xampp\htdocs\this\tcpdf\tcpdf.php on line 8366 Could you please tell me or guide me where is the problem. I am just running the example without changing anything. I am using xampp. The problem is with the location from where it tries to access the private key. Instead of '' like in their example use 'file://'.( dirname( FILE )).'./path/to/file'. This worked for me. I solved it by using: $certificate = 'file://'.realpath('..

PDF Signature digest

南笙酒味 提交于 2019-11-30 21:37:54
I have a quick question about calculating the digest of a PDF document to use for a digital signature (somewhat related to one of my earlier questions, I'm trying to figure out why you would need to know a client's certificate to create the correct digest). In Adobe's documentation about the PDF format the following is specified: A byte range digest shall be computed over a range of bytes in the file, that shall be indicated by the ByteRange entry in the signature dictionary. This range should be the entire file, including the signature dictionary but excluding the signature value itself (the

PHP How to parse pkcs7 signature blob?

守給你的承諾、 提交于 2019-11-30 20:39:49
I have a PKCS7 signature which i can get parsed contents from with openssl pkcs7 -inform DER -in signature.pkcs7 -print_certs -text But how do archieve the same output with PHPs openssl functions? Edit. I succeeded in creating a correct PEM file with the following function: function der2pem($der_data, $type="CERTIFICATE") { $pem = chunk_split(base64_encode($der_data), 64, "\n"); $pem = "-----BEGIN $type-----\n".$pem."-----END $type-----\n"; return $pem; } $data = der2pem($der_data, "PKCS7"); Im not however successfull in parsing the data with any of the functions mentioned in the PHP manual.

AES with padding pkcs7 c++ code

妖精的绣舞 提交于 2019-11-30 19:37:00
问题 I need an example of string encryption (in C++ -> I'm working on linux-Ubuntu) with aes-cbc256 and a padding: PKCS7 Please help. For the following code how can I set the IV to 0 and set the key value to a string value? I would also like to add the pkcs7 padding. I'm using the crypto++ lib (in Linux) // Driver.cpp // #include "stdafx.h" #include "cryptopp/dll.h" #include "cryptopp/default.h" #include "crypto++/osrng.h" using CryptoPP::AutoSeededRandomPool; #include <iostream> using std::cout;

Signing and Verifying on iOS using RSA

☆樱花仙子☆ 提交于 2019-11-29 20:29:47
How to sign and verify some data on iOS with an RSA key (preferably using the system own libcommonCrypto )? Since there hasn't been nearly any knowledge about signing and verifying found on StackOverflow and the Apple docs, I had to manually browse around in the iOS header files and found SecKeyRawSign and SecKeyRawVerify . The following lines of code seem to work. Signing NSData (using SHA256 with RSA): NSData* PKCSSignBytesSHA256withRSA(NSData* plainData, SecKeyRef privateKey) { size_t signedHashBytesSize = SecKeyGetBlockSize(privateKey); uint8_t* signedHashBytes = malloc(signedHashBytesSize

Is there any OpenSSL function to convert PKCS7 file to PEM

◇◆丶佛笑我妖孽 提交于 2019-11-29 11:36:45
Is there any openssl api function to convert PKCS7 file to PEM. I am able to convert a PKCS12 file to PEM using PKCS12_parse() function which returns key and certificate given the password. There is no similar function for pkcs7. My pkcs7 input has just the certificate in binary format. I am able to do the conversion using command openssl pkcs7 -inform DER -in input.p7b -printcerts -text How do I do this in a C program? I am able to read it to a PKCS7 structure like this FILE* fp; if (!(fp = fopen("ca.p7b", "rb"))) { fprintf(stderr, "Error reading input pkcs7 file\n" ); exit(1); } PKCS7 *p7;

Sign data using PKCS #7 in JAVA

浪尽此生 提交于 2019-11-29 07:50:23
问题 I want to sign a text file (may be a .exe file or something else in the future) using PKCS#7 and verify the signature using Java. What do I need to know? Where will I find an API ( .jar and documentation)? What are the steps I need to follow in order to sign data and verify the data? Please provide me code snippet if possible. 回答1: I reckon you need the following 2 Bouncy Castle jars to generate the PKCS7 digital signature: bcprov-jdk15on-147.jar (for JDK 1.5 - JDK 1.7) bcmail-jdk15on-147.jar