pkcs#7

How to sign pdf in Java using pdfbox

妖精的绣舞 提交于 2019-11-29 03:55:15
I am trying to sign pdf using pdfbox libraries. I have stuck now and realy need a help. This is my code: private static void signPdf(PDDocument document) throws Exception { PDSignature sig = new PDSignature(); sig.setFilter(COSName.ADOBE_PPKLITE); sig.setSubFilter(COSName.ADBE_PKCS7_DETACHED); sig.setByteRange(new int[] {'a','a','a','a'}); sig.setContents(new byte[]{(byte) 23, (byte) 23, (byte) 23, (byte) 23}); SignatureOptions options = new SignatureOptions(); document.addSignature(sig, new SignatureInterface() { public byte[] sign(InputStream content) throws SignatureException, IOException {

Verifying PKCS#7 certificates in Java

℡╲_俬逩灬. 提交于 2019-11-29 01:10:11
问题 Need some help with crypto routines in Java. Given a PKCS#7 signature, I want to verify all certificates it contains against a trusted store. I assume that all certificates contained in signature are in the correct order to form a valid certificate path (or chain, whatever), so that topmost (#0) is a signing certificate; next one (#1) is an intermediate certificate, used to sign #0; next one (#2) is another intermediate certificate, used to sign #1; and so on. The last certificate (#N) is

How to Read the certificates file from the PKCS7.p7b certificate file using openssl?

旧城冷巷雨未停 提交于 2019-11-29 00:29:33
I am getting PKCS7 file (p7b). I want to read the content of the file and extract certificate in X509 structure. How can I access individual Certificate from the PKCS container using openssl library? I've used the following program: #include <stdio.h> #include <openssl/pkcs7.h> #include <openssl/x509.h> #include <openssl/bio.h> #include <openssl/pem.h> int main(int argc, char **argv) { PKCS7 *p7 = NULL; BIO *in = BIO_new(BIO_s_file()); BIO *out = BIO_new(BIO_s_file()); int der = 0; /* Input from DER or PEM ? */ int text = 0; /* Dump text or output PEM ? */ STACK_OF(X509) *certs = NULL; int i;

Signing and Verifying on iOS using RSA

懵懂的女人 提交于 2019-11-28 17:10:11
问题 How to sign and verify some data on iOS with an RSA key (preferably using the system own libcommonCrypto )? 回答1: 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

Problems reading authenticating a SAML assertion in .Net using WSSecurityTokenSerializer

别等时光非礼了梦想. 提交于 2019-11-28 00:29:54
I have a SAML assertion that I wish to authenticate in .Net using WSSecurityTokenSerializer . I've got the key-chain and SAML XML, despite a few issues . First I get the SAML assertion from the HTTPS POST: // spec says "SAMLResponse=" string rawSamlData = Request["SAMLResponse"]; // read the base64 encoded bytes byte[] samlData = Convert.FromBase64String(rawSamlData); // read back into a UTF string string samlAssertion = Encoding.UTF8.GetString(samlData); // get the SAML data in an XML reader var assertionPostStream = new StringReader(samlAssertion); var reader = XmlReader.Create

AES-256 and PKCS7Padding fails in Java

天涯浪子 提交于 2019-11-27 18:34:38
问题 I have a couple of library, C#, PHP and Android where they all encrypt/decrypt a string in the same way so they are all compatible with each other, i.e. C# writes and encrypts data to a database and PHP can successfully decrypt it and return the original string. I now need to do the same thing with a standard Java application, so I've taken the code from my Android library and need libraries but I am getting an exception. As far as I know the code wasn't Android specific so it shouldn't be a

AES/CBC/PKCS5Padding vs AES/CBC/PKCS7Padding with 256 key size performance java

烂漫一生 提交于 2019-11-27 17:53:27
I am currently using AES/CBC/PKCS5Padding for encrypting files in Java with 256 bytes key size, but while searching I found on stackexchange PKCS#5-PKCS#7 Padding and it is mentioned, PKCS#5 padding is a subset of PKCS#7 padding for 8 byte block sizes So I want to know Will the performance of AES/CBC/PKCS7Padding will be better then AES/CBC/PKCS5Padding for the above configuration? How can we configure the block size in Java as it is mentioned PKCS#7 padding would work for any block size from 1 to 255 bytes. My sample code is, SecureRandom rnd = new SecureRandom(); IvParameterSpec iv = new

How to sign pdf in Java using pdfbox

半腔热情 提交于 2019-11-27 16:12:23
问题 I am trying to sign pdf using pdfbox libraries. I have stuck now and realy need a help. This is my code: private static void signPdf(PDDocument document) throws Exception { PDSignature sig = new PDSignature(); sig.setFilter(COSName.ADOBE_PPKLITE); sig.setSubFilter(COSName.ADBE_PKCS7_DETACHED); sig.setByteRange(new int[] {'a','a','a','a'}); sig.setContents(new byte[]{(byte) 23, (byte) 23, (byte) 23, (byte) 23}); SignatureOptions options = new SignatureOptions(); document.addSignature(sig, new

Create pkcs7 signature from file digest

纵饮孤独 提交于 2019-11-27 14:15:13
问题 Currently i have a client-server application that, given a PDF file, signs it (with the server certificate), attachs the signature with the original file and returns the output back to the client (all of this is achieved with PDFBox). I have a Signature handler, which is my External Signing Support (where content is the PDF file) public byte[] sign(InputStream content) throws IOException { try { System.out.println("Generating CMS signed data"); CMSSignedDataGenerator generator = new

Problems reading authenticating a SAML assertion in .Net using WSSecurityTokenSerializer

我是研究僧i 提交于 2019-11-26 21:42:36
问题 I have a SAML assertion that I wish to authenticate in .Net using WSSecurityTokenSerializer . I've got the key-chain and SAML XML, despite a few issues. First I get the SAML assertion from the HTTPS POST: // spec says "SAMLResponse=" string rawSamlData = Request["SAMLResponse"]; // read the base64 encoded bytes byte[] samlData = Convert.FromBase64String(rawSamlData); // read back into a UTF string string samlAssertion = Encoding.UTF8.GetString(samlData); // get the SAML data in an XML reader