use of org.eclipse.osgi.storage.bundlefile.BundleEntry in project rt.equinox.framework by eclipse.
the class SignatureBlockProcessor method processSigner.
private void processSigner(BundleFile bf, byte[] manifestBytes, String signer) throws IOException, SignatureException, InvalidKeyException, CertificateException, NoSuchAlgorithmException, NoSuchProviderException {
BundleEntry be = bf.getEntry(signer);
byte[] pkcs7Bytes = readIntoArray(be);
int dotIndex = signer.lastIndexOf('.');
be = bf.getEntry(signer.substring(0, dotIndex) + DOT_SF);
byte[] sfBytes = readIntoArray(be);
// Step 1, verify the .SF file is signed by the private key that corresponds to the public key
// in the .RSA/.DSA file
String baseFile = bf.getBaseFile() != null ? bf.getBaseFile().toString() : null;
PKCS7Processor processor = new PKCS7Processor(pkcs7Bytes, 0, pkcs7Bytes.length, signer, baseFile);
// call the Step 1 in the Jar File Verification algorithm
processor.verifySFSignature(sfBytes, 0, sfBytes.length);
// algorithm used
String digAlg = getDigAlgFromSF(sfBytes);
if (digAlg == null)
throw new SignatureException(NLS.bind(SignedContentMessages.SF_File_Parsing_Error, new String[] { bf.toString() }));
// get the digest results
// Process the Step 2 in the Jar File Verification algorithm
// Get the manifest out of the signature file and make sure
// it matches MANIFEST.MF
verifyManifestAndSignatureFile(manifestBytes, sfBytes);
// create a SignerInfo with the processed information
SignerInfoImpl signerInfo = new SignerInfoImpl(processor.getCertificates(), null, digAlg);
if ((supportFlags & SignedBundleHook.VERIFY_RUNTIME) != 0)
// only populate the manifests digest information for verifying content at runtime
populateMDResults(manifestBytes, signerInfo);
signerInfos.add(signerInfo);
// check for tsa signers
Certificate[] tsaCerts = processor.getTSACertificates();
Date signingTime = processor.getSigningTime();
if (tsaCerts != null && signingTime != null) {
SignerInfoImpl tsaSignerInfo = new SignerInfoImpl(tsaCerts, null, digAlg);
if (tsaSignerInfos == null)
tsaSignerInfos = new HashMap<>(2);
tsaSignerInfos.put(signerInfo, new Object[] { tsaSignerInfo, signingTime });
}
}
Aggregations