File tree Expand file tree Collapse file tree 2 files changed +14
-5
lines changed
src/java.base/share/classes/sun/security/pkcs
test/jdk/sun/security/x509/AlgorithmId Expand file tree Collapse file tree 2 files changed +14
-5
lines changed Original file line number Diff line number Diff line change @@ -277,11 +277,13 @@ public PKCS9Attribute getAttribute(String name) {
277277 */
278278 public PKCS9Attribute [] getAttributes () {
279279 PKCS9Attribute [] attribs = new PKCS9Attribute [attributes .size ()];
280- ObjectIdentifier oid ;
281280
282281 int j = 0 ;
283282 for (int i =1 ; i < PKCS9Attribute .PKCS9_OIDS .length &&
284283 j < attribs .length ; i ++) {
284+ if (PKCS9Attribute .PKCS9_OIDS [i ] == null ) {
285+ continue ;
286+ }
285287 attribs [j ] = getAttribute (PKCS9Attribute .PKCS9_OIDS [i ]);
286288
287289 if (attribs [j ] != null )
@@ -325,11 +327,13 @@ public String toString() {
325327 StringBuilder sb = new StringBuilder (200 );
326328 sb .append ("PKCS9 Attributes: [\n \t " );
327329
328- ObjectIdentifier oid ;
329330 PKCS9Attribute value ;
330331
331332 boolean first = true ;
332333 for (int i = 1 ; i < PKCS9Attribute .PKCS9_OIDS .length ; i ++) {
334+ if (PKCS9Attribute .PKCS9_OIDS [i ] == null ) {
335+ continue ;
336+ }
333337 value = getAttribute (PKCS9Attribute .PKCS9_OIDS [i ]);
334338
335339 if (value == null ) continue ;
@@ -340,7 +344,7 @@ public String toString() {
340344 else
341345 sb .append (";\n \t " );
342346
343- sb .append (value . toString () );
347+ sb .append (value );
344348 }
345349
346350 sb .append ("\n \t ] (end PKCS9 Attributes)" );
Original file line number Diff line number Diff line change 11/*
2- * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved.
2+ * Copyright (c) 2012, 2021, Oracle and/or its affiliates. All rights reserved.
33 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
44 *
55 * This code is free software; you can redistribute it and/or modify it
2323
2424/*
2525 * @test
26- * @bug 7180907
26+ * @bug 7180907 8277224
2727 * @summary Jarsigner -verify fails if rsa file used sha-256 with authenticated attributes
2828 * @modules java.base/sun.security.pkcs
2929 * java.base/sun.security.tools.keytool
@@ -60,8 +60,13 @@ public static void main(String[] args) throws Exception {
6060 PKCS9Attributes authed = new PKCS9Attributes (new PKCS9Attribute []{
6161 new PKCS9Attribute (PKCS9Attribute .CONTENT_TYPE_OID , ContentInfo .DATA_OID ),
6262 new PKCS9Attribute (PKCS9Attribute .MESSAGE_DIGEST_OID , md .digest (data )),
63+ new PKCS9Attribute (PKCS9Attribute .SIGNATURE_TIMESTAMP_TOKEN_OID , "test" .getBytes ())
6364 });
6465
66+ // test PKCS9Attributes.toString(), PKCS9Attributes.getAttributes()
67+ System .out .println (authed );
68+ authed .getAttributes ();
69+
6570 Signature s = Signature .getInstance ("SHA256withRSA" );
6671 s .initSign (cakg .getPrivateKey ());
6772 s .update (authed .getDerEncoding ());
You can’t perform that action at this time.
0 commit comments