I have to produce a function that take a signed or crypted input file and determine if it's PGP,SMIME or PEM file and return if it's crypted or signed. so the return should be for example 'PGP-SIGNED' or 'SMIME-CRYPTED'
I'm reading the first line of the file to see if it contains BEGIN PGP so it's a PGP File
or Only BEGIN => pem
or contains smime
after, to determine which operation Signature/Encryption :
for PGP:
I call
PGPObjectFactory factory = new PGPObjectFactory (inputFile ,new BcKeyFingerPrintCalculator());
Object o = factory.nextObject();
and depending on the type of the o object I can say if it's encryption or signature.
For smime:
I check the smime.getContentType()
I don't know how to check the operation for pem file.
Is there a proper way using bouncycastle java to do these controls?