pkcs7 | Implements a subset of PKCS # 7/Crytpographic Message
kandi X-RAY | pkcs7 Summary
kandi X-RAY | pkcs7 Summary
pkcs7 implements parsing and creating signed and enveloped messages.
Support
Quality
Security
License
Reuse
Top functions reviewed by kandi - BETA
- readObject reads an object .
- Encrypt encrypts the given content with the given recipients .
- encryptAES128GCM encrypts data using AES128GCM
- getSignatureAlgorithmFromAI returns the signature algorithm associated with a pkix .
- verifySignature verifies the signature of a PKCS7 signature .
- encryptDESCBC encrypts and returns the encrypted content .
- parseSignedData parses a signed data and returns a PKCS7 structure .
- Parse parses a PKCS7 from data .
- DegenerateCertificate creates a SignedData from a certificate .
- NewSignedData initializes a SignedData from a byte slice .
pkcs7 Key Features
pkcs7 Examples and Code Snippets
Community Discussions
Trending Discussions on pkcs7
QUESTION
We are programmatically creating PDF using our in house lib (C++) by adding all the required objects so that PDF readers can render them properly. Currently we are enhancing the lib to support digital signatures in PDF. Our users will use USB token or Windows certificates to sign the PDF. On studying raw PDF file with digital signature, we were able to make sense of all the objects except for the contents of Sig type object.
...ANSWER
Answered 2021-Jun-10 at 16:48Ok, the signature container is embedded correctly.
But there are issues with the signature container itself:
Both in the
SignedData.digestAlgorithms
collection and in theSignerInfo.digestAlgorithm
value you have used the OID of SHA1withRSA, but that is a full signature algorithm, not the mere digest algorithm SHA1 expected there.Then the SHA1 hash of the signed bytes is BB78A402F7A537A34D6892B83881266501A691A8 but the hash you signed is 90E28B8A0D8E48691DAFE2BA10A4761FFFDCCD3D. This might be because you hash buffer2 and
buffer2 has empty contents data (/Contents <>)
The hex string delimiters '<' and '>' also belong to the contents value and, therefore, must also be removed in buffer2.
Furthermore, your signature is very weak:
- It uses SHA1 as hash algorithm. SHA1 meanwhile has been recognized as too weak a hash algorithm for document signatures.
- It doesn't use signed attributes, neither the ESS signing certificate nor the algorithm identifier protection attribute. Many validation policies require such special attributes.
QUESTION
I am trying encrypting in JS front end and decrypt in python backend using AES GCM cryptographic algorithm. I am using Web cryptography api for JS front end and python cryptography library for python backend as cryptographic library. I have fixed the IV for now in both side. I have implemented encryption-decryption code in both side, they work on each side. But I think the padding is done differently, can't seem to figure out how the padding is done in web cryptography api. Here is the encryption and decryption for the python backend:
...ANSWER
Answered 2021-Jun-14 at 18:01GCM is a stream cipher mode and therefore does not require padding. During encryption, an authentication tag is implicitly generated, which is used for authentication during decryption. Also, an IV/nonce of 12 bytes is recommended for GCM.
The posted Python code unnecessarily pads and doesn't take the authentication tag into account, unlike the JavaScript code, which may be the main reason for the different ciphertexts. Whether this is the only reason and whether the JavaScript code implements GCM correctly, is difficult to say, since the getMessageEncoding()
method was not posted, so testing this was not possible.
Also, both codes apply a 16 bytes IV/nonce instead of the recommended 12 bytes IV/nonce.
Cryptography offers two possible implementations for GCM. One implementation uses the architecture of the non-authenticating modes like CBC. The posted Python code applies this design, but does not take authentication into account and therefore implements GCM incompletely. A correct example for this design can be found here.
Cryptography generally recommends the other approach for GCM (s. the Danger note), namely the AESGCM
class, which performs implicit authentication so that this cannot be accidentally forgotten or incorrectly implemented.
The following implementation uses the AESGCM
class (and also takes into account the optional additional authenticated data):
QUESTION
I want implement a elliptic curve diffie hellman using HKDF as key derivation function. I am using a python backend and (vanilla) javascript in frontend. I am using python cryptography library in backend and Web Crypto api in frontend as cryptographic library. I created ECDH key pair in both side and exchanged the pbulic keys. Now I am trying to create the AES shared key with the exchanged public key and private key along with HKDF algorithm. I am able to do it in the python backend (I followed this example for the python code):
...ANSWER
Answered 2021-Jun-13 at 11:02The referenced Python code uses P-384 (aka secp384r1) as elliptic curve. This is compatible with the WebCrypto API, which supports three curves P-256 (aka secp256r1), P-384 and P-521 (aka secp521r1), see EcKeyImportParams
.
The following WebCrypto code generates a shared secret using ECDH and derives an AES key from the shared secret using HKDF. In detail the following happens:
- To allow comparison of the derived key with that of the referenced Python code, predefined EC keys are applied. The private key is imported as PKCS#8, the public key as X.509/SPKI. Note that due to a Firefox bug concerning the import of EC keys, the script below cannot be run in the Firefox browser.
- After the import the shared secret is created with ECDH using
deriveBits()
(and notderiveKey()
). - The shared secret is imported with
importKey()
and then the AES key is derived using HKDF, again withderiveBits()
.
QUESTION
I receive data from a third party at an API that contains encrypted data. They provided me with a Passphrase do decrypt the content of the Json file, but I do not get any result; so they provided me with the code they generate the encryption which is written in VB.NET:
...ANSWER
Answered 2021-Jun-11 at 06:29The VB code derives the key from the passhprase with MD5. TripleDES (aka 3DES) with a 16 bytes key (2TDEA) is used as the algorithm. ECB is applied as the mode. A possible decryption with CryptoJS is:
QUESTION
I tried to install the https://pypi.org/project/keyrings.google-artifactregistry-auth/ package, but installation failed because it claims that Rust is required to install:
This package requires Rust >=1.41.0.
How can I install this? Do I need to install Rust?
Full output is here:
...ANSWER
Answered 2021-May-24 at 18:59The issue is that your pip
version is too old to install one of this project's subdependencies, cryptography
, which is using newer features.
Upgrading pip
with the following will make it possible to install this package:
QUESTION
I am using aws cloudHSM and itext7 to sign the pdf. Everything is fine till i am not enabling LTV.
But after enabling LTV getting error "Atleast one signature has problem" and showing reason signature byte range is invalid.
Below is the code
...ANSWER
Answered 2021-May-08 at 07:22In your architecture you have a ByteArrayOutputStream
parameter in which you retrieve the pdf to LTV-enable and in which you also in the end return the LTV-enabled result pdf.
In such an architecture have to clear the ByteArrayOutputStream
between retrieving the original content from it and adding the new content to it.
In your case, therefore, you have to clear it between
QUESTION
I am a Chinese software developer, I am now implementing such a function, using Android client to digitally sign PDF, my implementation is like this
- Create a blank signature on the server
- Send PDF hash with blank signature to Android client, and Android client signs hash
- Use makesignature. Signdeferred () to merge the signature content in the server Now I encounter such a problem that the PDF after signing cannot be verified by the PDF reader. It shows that the PDF file has been tampered, It should be noted that I use sm3withsm2 algorithm. Adobe reader can't verify it. We have our own reader
https://drive.google.com/file/d/127nVvJ0qtSdG53jM0_GUP-WORYrQ5TBo/view?usp=sharing Now I add the PDF file address, who can help me analyze the problem
...ANSWER
Answered 2021-May-06 at 12:34When calculating the hash of the to-be-signed attributes, you use the then current time as value of the signing time attribute:
QUESTION
I have a scenario where data is encrypted from the API and then decrypted in typescript. I have used cryptoJS for decryption in typescript. Following is my decryption code:
...ANSWER
Answered 2021-Apr-28 at 02:05"First 16 characters wrong; everything else looks good" typically means you got the IV wrong.
Everything in the code you provided looks legit; I suspect that the caller to decrypt is not passing the correct IV value.
QUESTION
I am attempting to encrypt/decrypt files in C# ASP NET 5.0 and I can get it to work for .txt files and regular strings of course. But if I attempt to encrypt a PDF file then decrypt it, it is corrupted and I cannot open it. I am just using EBC right now, I know it isn't secure but I am just trying to test it out before I add in the other options.
...ANSWER
Answered 2021-May-02 at 19:17As stated in my comment above, there is an error in your code that is not visible because you hide the exceptions with an empty catch block. The exception is a NotSupportedException and the message is
FlushFinalBlock() method was called twice on a CryptoStream. It can only be called once
The encryption works fine with text files that are under 1024 bytes in length but any file (also text files) with a larger size will crash because the code tries to call two or more time the cryptoStream.FlushFinalBlock();
So, I have tested this change to your code and it works
QUESTION
The first image is from a pdf signature which is LTV enabled. This document is not created by me.
In the revocation information, it shows the following text:
The selected certificate is considered valid because it has not been revoked as verified using the Online Certificate Status Protocol (OCSP) response that was embedded in the signature.
I do sign a pdf document using iText and I also apply an OCSP.
...ANSWER
Answered 2021-Apr-28 at 15:57You add one OCSP response, the one you retrieve here:
Community Discussions, Code Snippets contain sources that include Stack Exchange Network
Vulnerabilities
No vulnerabilities reported
Install pkcs7
Support
Reuse Trending Solutions
Find, review, and download reusable Libraries, Code Snippets, Cloud APIs from over 650 million Knowledge Items
Find more librariesStay Updated
Subscribe to our newsletter for trending solutions and developer bootcamps
Share this Page