8268506: More Manifest Digests

Reviewed-by: xuelei, ahgross, weijun, rhalade
This commit is contained in:
Hai-May Chao 2021-06-30 18:02:46 +00:00 committed by Henry Jen
parent ab9170957f
commit 790dcc667d
3 changed files with 21 additions and 7 deletions

View file

@ -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) {

View file

@ -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());