From 0071613a45a685c4249c7d08978a2f9a68109666 Mon Sep 17 00:00:00 2001 From: juh Date: Thu, 8 Aug 2013 17:06:40 -0700 Subject: [PATCH] 8022461: Fix lint warnings in sun.security.{provider,rsa,x509} Reviewed-by: darcy, weijun, xuelei, mullan --- .../classes/sun/security/provider/DSAPublicKey.java | 8 +++++--- .../classes/sun/security/rsa/RSAPublicKeyImpl.java | 11 ++++++----- src/share/classes/sun/security/rsa/RSASignature.java | 4 +++- src/share/classes/sun/security/x509/AlgIdDSA.java | 4 ++-- src/share/classes/sun/security/x509/X509Key.java | 3 ++- 5 files changed, 18 insertions(+), 12 deletions(-) diff --git a/src/share/classes/sun/security/provider/DSAPublicKey.java b/src/share/classes/sun/security/provider/DSAPublicKey.java index a8340f35d..883e52bbe 100644 --- a/src/share/classes/sun/security/provider/DSAPublicKey.java +++ b/src/share/classes/sun/security/provider/DSAPublicKey.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1996, 2005, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1996, 2013, 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 @@ -37,6 +37,7 @@ import java.security.interfaces.DSAParams; import sun.security.x509.X509Key; import sun.security.x509.AlgIdDSA; +import sun.security.util.BitArray; import sun.security.util.Debug; import sun.security.util.DerValue; import sun.security.util.DerInputStream; @@ -88,8 +89,9 @@ implements java.security.interfaces.DSAPublicKey, Serializable { algid = new AlgIdDSA(p, q, g); try { - key = new DerValue(DerValue.tag_Integer, + byte[] keyArray = new DerValue(DerValue.tag_Integer, y.toByteArray()).toByteArray(); + setKey(new BitArray(keyArray.length*8, keyArray)); encode(); } catch (IOException e) { throw new InvalidKeyException("could not DER encode y: " + @@ -142,7 +144,7 @@ implements java.security.interfaces.DSAPublicKey, Serializable { protected void parseKeyBits() throws InvalidKeyException { try { - DerInputStream in = new DerInputStream(key); + DerInputStream in = new DerInputStream(getKey().toByteArray()); y = in.getBigInteger(); } catch (IOException e) { throw new InvalidKeyException("Invalid key: y value\n" + diff --git a/src/share/classes/sun/security/rsa/RSAPublicKeyImpl.java b/src/share/classes/sun/security/rsa/RSAPublicKeyImpl.java index d0ef2ebb9..52c0d6718 100644 --- a/src/share/classes/sun/security/rsa/RSAPublicKeyImpl.java +++ b/src/share/classes/sun/security/rsa/RSAPublicKeyImpl.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2008, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 2013, 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 @@ -67,9 +67,10 @@ public final class RSAPublicKeyImpl extends X509Key implements RSAPublicKey { DerOutputStream out = new DerOutputStream(); out.putInteger(n); out.putInteger(e); - DerValue val = - new DerValue(DerValue.tag_Sequence, out.toByteArray()); - key = val.toByteArray(); + byte[] keyArray = + new DerValue(DerValue.tag_Sequence, + out.toByteArray()).toByteArray(); + setKey(new BitArray(keyArray.length*8, keyArray)); } catch (IOException exc) { // should never occur throw new InvalidKeyException(exc); @@ -104,7 +105,7 @@ public final class RSAPublicKeyImpl extends X509Key implements RSAPublicKey { */ protected void parseKeyBits() throws InvalidKeyException { try { - DerInputStream in = new DerInputStream(key); + DerInputStream in = new DerInputStream(getKey().toByteArray()); DerValue derValue = in.getDerValue(); if (derValue.tag != DerValue.tag_Sequence) { throw new IOException("Not a SEQUENCE"); diff --git a/src/share/classes/sun/security/rsa/RSASignature.java b/src/share/classes/sun/security/rsa/RSASignature.java index 435e283ad..959700f22 100644 --- a/src/share/classes/sun/security/rsa/RSASignature.java +++ b/src/share/classes/sun/security/rsa/RSASignature.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2012, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 2013, 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 @@ -244,12 +244,14 @@ public abstract class RSASignature extends SignatureSpi { } // set parameter, not supported. See JCA doc + @Deprecated protected void engineSetParameter(String param, Object value) throws InvalidParameterException { throw new UnsupportedOperationException("setParameter() not supported"); } // get parameter, not supported. See JCA doc + @Deprecated protected Object engineGetParameter(String param) throws InvalidParameterException { throw new UnsupportedOperationException("getParameter() not supported"); diff --git a/src/share/classes/sun/security/x509/AlgIdDSA.java b/src/share/classes/sun/security/x509/AlgIdDSA.java index 219ef5c00..20f0d9156 100644 --- a/src/share/classes/sun/security/x509/AlgIdDSA.java +++ b/src/share/classes/sun/security/x509/AlgIdDSA.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1996, 2003, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1996, 2013, 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 @@ -96,7 +96,7 @@ class AlgIdDSA extends AlgorithmId implements DSAParams * Default constructor. The OID and parameters must be * deserialized before this algorithm ID is used. */ - // XXX deprecated for general use + @Deprecated public AlgIdDSA () {} AlgIdDSA (DerValue val) throws IOException diff --git a/src/share/classes/sun/security/x509/X509Key.java b/src/share/classes/sun/security/x509/X509Key.java index 135aa2e32..789b7b8dc 100644 --- a/src/share/classes/sun/security/x509/X509Key.java +++ b/src/share/classes/sun/security/x509/X509Key.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1996, 2011, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1996, 2013, 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 @@ -79,6 +79,7 @@ public class X509Key implements PublicKey { * Added to keep the byte[] key form consistent with the BitArray * form. Can de deleted when byte[] key is deleted. */ + @Deprecated private int unusedBits = 0; /* BitArray form of key */ -- GitLab