mirror of
https://github.com/openjdk/jdk.git
synced 2026-03-15 18:33:41 +00:00
8268506: More Manifest Digests
Reviewed-by: xuelei, ahgross, weijun, rhalade
This commit is contained in:
parent
ab9170957f
commit
790dcc667d
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 1997, 2019, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 1997, 2021, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
@ -331,8 +331,12 @@ public class ManifestDigester {
|
||||
* @see #MF_MAIN_ATTRS
|
||||
*/
|
||||
public Entry getMainAttsEntry(boolean oldStyle) {
|
||||
mainAttsEntry.oldStyle = oldStyle;
|
||||
return mainAttsEntry;
|
||||
if (mainAttsEntry != null) {
|
||||
mainAttsEntry.oldStyle = oldStyle;
|
||||
return mainAttsEntry;
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
public Entry get(String name) {
|
||||
|
||||
@ -543,6 +543,10 @@ public class SignatureFileVerifier {
|
||||
MessageDigest digest = getDigest(algorithm);
|
||||
if (digest != null) {
|
||||
ManifestDigester.Entry mde = md.getMainAttsEntry(false);
|
||||
if (mde == null) {
|
||||
throw new SignatureException("Manifest Main Attribute check " +
|
||||
"failed due to missing main attributes entry");
|
||||
}
|
||||
byte[] computedHash = mde.digest(digest);
|
||||
byte[] expectedHash =
|
||||
Base64.getMimeDecoder().decode((String)se.getValue());
|
||||
|
||||
@ -793,13 +793,19 @@ public final class JarSigner {
|
||||
ManifestDigester oldMd = new ManifestDigester(mfRawBytes);
|
||||
ManifestDigester newMd = new ManifestDigester(mfNewRawBytes);
|
||||
|
||||
ManifestDigester.Entry oldEntry = oldMd.getMainAttsEntry();
|
||||
|
||||
// main attributes
|
||||
if (manifest.getMainAttributes().equals(
|
||||
oldManifest.getMainAttributes())
|
||||
if (oldEntry != null
|
||||
&& manifest.getMainAttributes().equals(
|
||||
oldManifest.getMainAttributes())
|
||||
&& (manifest.getEntries().isEmpty() ||
|
||||
oldMd.getMainAttsEntry().isProperlyDelimited())) {
|
||||
oldMd.getMainAttsEntry().reproduceRaw(baos);
|
||||
oldEntry.isProperlyDelimited())) {
|
||||
oldEntry.reproduceRaw(baos);
|
||||
} else {
|
||||
if (newMd.getMainAttsEntry() == null) {
|
||||
throw new SignatureException("Error getting new main attribute entry");
|
||||
}
|
||||
newMd.getMainAttsEntry().reproduceRaw(baos);
|
||||
}
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user