PKCS7
Hello,
I'm chasing my tail and hoping someone can help out?
Client sends me a .p7b (PKCS#7) file which includes key, the issuing CA, and the Root CA to be used Java code on my end. Next, client is sending me two things:
1) Signature data
2) Encrypted data
I need to verify the signature and then decrypt the encrypted data. I've tried importing this .p7b (PKCS#7) file into a keystore. No go, so imported into Internet Explorer, then exported and was able to import into keystore. Heck, not sure if keystore is even the way to go. Now, I'm starting to look at the Bouncy Castle classes. Feel like going in circles.
Any suggestions? Can someone point me in the right direction?
Thank you,
Todd
[752 byte] By [
superglooa] at [2007-10-2 15:00:40]

This is where I am without Bouncy Castle code:
public void testSig(String filename) throws Exception {
File file = new File(filename);
FileInputStream is = new FileInputStream(file);
keystore = KeyStore.getInstance(KeyStore.getDefaultType());
keystore.load(is, password.toCharArray());
X509Certificate cert = (X509Certificate)keystore.getCertificate("root");
// Future DataS field
File inFile = new File("c:/temp/statemp/signtest.txt");
FileReader fileReader = new FileReader(inFile);
BufferedReader bufferedReader = new BufferedReader(fileReader);
ByteArrayOutputStream baos = new ByteArrayOutputStream();
String line = null;
while((line = bufferedReader.readLine())!=null){
byte[] data = line.getBytes();
baos.write(data);
}
Signature sig = Signature.getInstance("SHA1withRSA");
sig.initVerify(cert.getPublicKey());
byte[] sigbytes = baos.toByteArray();
if(isBase64Encoded(sigbytes)){
try{
sun.misc.BASE64Decoder dec = new sun.misc.BASE64Decoder() ;
sigbytes = dec.decodeBuffer(new String(sigbytes));
logger.info("Signature file is BASE64 encoded") ;
}
catch(IOException ioe) {System.out.println("Problem decoding from b64") ; }
}
logger.info("Verified: " +sig.verify(sigbytes));
}
In order to import the .p7b file into a Java keystore file, I need to import into Internet Explorer then export back out the file system. Client creates .p7b in C#. Then, I was able to import as "root" alias into the keystore.
filename is the name and path of keystore file
signtest.txt file contains base64 encoded signature data for testing
Verified: is always false.
Ugh. Any Thoughts? Right track?