I need to generate a CMS with SHA1+RSA detached signature in PEM format over a xml file input. I need to make this from Java code in runtime. I need to avoid the use of an external tool like OpenSSL. This is because we need invoke some services with the generated signature from Java and manage error properly if an
Tag: cryptography
Fixed length 64 Bytes EC P-256 Signature with JCE
I need a fixed length 64 Byte ECDSA signature with the NIST P-256 Curve. The implementation hast to use JCE. The following code sample can generate a signature and verify it. Provider provSign = …
How to load public certificate from pem file?
I was trying to extract RES public key from the file below Here is the code i did.. But It throws out java.security.InvalidKeyException: IOException: ObjectIdentifier() — data isn’t an object ID What’s the appropriate way to extract RES Public key from a file.. Answer An X.509 certificate and an X509EncodedKeySpec are quite different structures, and trying to parse a cert
For PBKDF2, using HMAC-SHA256 is more secure than using HMAC-SHA-1?
I’m looking for the proper Java algorithm for password encryption, and I found that Java SDK provides PBKDF2WithHmacSHA1, but not PBKDF2WithHmacSHA256. I heard that HMAC-SHA256 will take more time than HMAC-SHA-1 does. Since system resources are limited, I’m going to apply different iteration values to make them most secure as long as service requirements can bear it. Even with the
Extract raw certificate from PKCS#7 file in JAVA
I would like to achieve the same what this openssl command performs, but programmatically in Java: openssl pkcs7 -in toBeExported.p7c -inform DER -out certificate.pem -print_certs which means that …
Generate x509certificate certpath in JAVA
I successfully make X.509 certificate from certificate request. However, I need to insert CERT Path informatin in the X.509 certificate. I know that I have to use CertPathBuilder method but I don’t know how to use it. could you give me an code example that suitable for the following code? Answer The below code may help you
C# and Java DES Encryption value are not identical
I am trying to encrypt the same data using C# and Java. If the data is more than 7 bytes then Java and C#’s encrypted value are not identical. Input 1: a java output: FrOzOp/2Io8= C# output: FrOzOp/2Io8= Input 2: abc j : H9A/ahl8K7I= c#: H9A/ahl8K7I= Input 3: aaaaaaaa (Problem) j : Gxl7e0aWPd7j6l7uIEuMxA== c#: Gxl7e0aWPd7sf1xR6hK4VQ== Here is the implementation of
Why does SSL handshake give ‘Could not generate DH keypair’ exception?
When I make an SSL connection with some IRC servers (but not others – presumably due to the server’s preferred encryption method) I get the following exception: Final cause: An example of a server that demonstrates this problem is aperture.esper.net:6697 (this is an IRC server). An example of a server that does not demonstrate the problem is kornbluth.freenode.net:6697. [Not surprisingly,
RSA in bouncycastle for java – How is ciphertext randomization gained?
I´m acutally using bouncycastle library for my applications RSA crypto. My question is: When I encrypt one plaintext two times using the same key, It will lead to two different ciphertexts, so there has to be some kind of randomization in bouncycastles implementation (RSA itself is not randomized, so enc(a, k) is always the same). Can anyone please tell me,
Why do people use bouncycastle instead of Java’s built in JCE provider? What is the difference?
Why do people use bouncycastle instead of Java Cryptography Extension? What is the difference? Answer BouncyCastle has many more cipher suites and algorithms than the default JCE provided by Sun. In addition to that, BouncyCastle has lots of utilities for reading arcane formats like PEM and ASN.1 that no sane person would want to rewrite themselves.