jdk/src/java.base/share/classes/java/security/Signature.java
changeset 26736 5a93000b26cd
parent 25859 3317bb8137f4
child 27077 c943ca4a3380
equal deleted inserted replaced
26735:4502faa0cc22 26736:5a93000b26cd
     1 /*
     1 /*
     2  * Copyright (c) 1996, 2013, Oracle and/or its affiliates. All rights reserved.
     2  * Copyright (c) 1996, 2014, Oracle and/or its affiliates. All rights reserved.
     3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
     3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
     4  *
     4  *
     5  * This code is free software; you can redistribute it and/or modify it
     5  * This code is free software; you can redistribute it and/or modify it
     6  * under the terms of the GNU General Public License version 2 only, as
     6  * under the terms of the GNU General Public License version 2 only, as
     7  * published by the Free Software Foundation.  Oracle designates this
     7  * published by the Free Software Foundation.  Oracle designates this
   118 
   118 
   119 public abstract class Signature extends SignatureSpi {
   119 public abstract class Signature extends SignatureSpi {
   120 
   120 
   121     private static final Debug debug =
   121     private static final Debug debug =
   122                         Debug.getInstance("jca", "Signature");
   122                         Debug.getInstance("jca", "Signature");
       
   123 
       
   124     private static final Debug pdebug =
       
   125                         Debug.getInstance("provider", "Provider");
       
   126     private static final boolean skipDebug =
       
   127         Debug.isOn("engine=") && !Debug.isOn("signature");
   123 
   128 
   124     /*
   129     /*
   125      * The algorithm for this signature object.
   130      * The algorithm for this signature object.
   126      * This value is used to map an OID to the particular algorithm.
   131      * This value is used to map an OID to the particular algorithm.
   127      * The mapping is done in AlgorithmObject.algOID(String algorithm)
   132      * The mapping is done in AlgorithmObject.algOID(String algorithm)
   449      */
   454      */
   450     public final void initVerify(PublicKey publicKey)
   455     public final void initVerify(PublicKey publicKey)
   451             throws InvalidKeyException {
   456             throws InvalidKeyException {
   452         engineInitVerify(publicKey);
   457         engineInitVerify(publicKey);
   453         state = VERIFY;
   458         state = VERIFY;
       
   459 
       
   460         if (!skipDebug && pdebug != null) {
       
   461             pdebug.println("Signature." + algorithm +
       
   462                 " verification algorithm from: " + this.provider.getName());
       
   463         }
   454     }
   464     }
   455 
   465 
   456     /**
   466     /**
   457      * Initializes this object for verification, using the public key from
   467      * Initializes this object for verification, using the public key from
   458      * the given certificate.
   468      * the given certificate.
   493         }
   503         }
   494 
   504 
   495         PublicKey publicKey = certificate.getPublicKey();
   505         PublicKey publicKey = certificate.getPublicKey();
   496         engineInitVerify(publicKey);
   506         engineInitVerify(publicKey);
   497         state = VERIFY;
   507         state = VERIFY;
       
   508 
       
   509         if (!skipDebug && pdebug != null) {
       
   510             pdebug.println("Signature." + algorithm +
       
   511                 " verification algorithm from: " + this.provider.getName());
       
   512         }
   498     }
   513     }
   499 
   514 
   500     /**
   515     /**
   501      * Initialize this object for signing. If this method is called
   516      * Initialize this object for signing. If this method is called
   502      * again with a different argument, it negates the effect
   517      * again with a different argument, it negates the effect
   509      */
   524      */
   510     public final void initSign(PrivateKey privateKey)
   525     public final void initSign(PrivateKey privateKey)
   511             throws InvalidKeyException {
   526             throws InvalidKeyException {
   512         engineInitSign(privateKey);
   527         engineInitSign(privateKey);
   513         state = SIGN;
   528         state = SIGN;
       
   529 
       
   530         if (!skipDebug && pdebug != null) {
       
   531             pdebug.println("Signature." + algorithm +
       
   532                 " signing algorithm from: " + this.provider.getName());
       
   533         }
   514     }
   534     }
   515 
   535 
   516     /**
   536     /**
   517      * Initialize this object for signing. If this method is called
   537      * Initialize this object for signing. If this method is called
   518      * again with a different argument, it negates the effect
   538      * again with a different argument, it negates the effect
   527      */
   547      */
   528     public final void initSign(PrivateKey privateKey, SecureRandom random)
   548     public final void initSign(PrivateKey privateKey, SecureRandom random)
   529             throws InvalidKeyException {
   549             throws InvalidKeyException {
   530         engineInitSign(privateKey, random);
   550         engineInitSign(privateKey, random);
   531         state = SIGN;
   551         state = SIGN;
       
   552 
       
   553         if (!skipDebug && pdebug != null) {
       
   554             pdebug.println("Signature." + algorithm +
       
   555                 " signing algorithm from: " + this.provider.getName());
       
   556         }
   532     }
   557     }
   533 
   558 
   534     /**
   559     /**
   535      * Returns the signature bytes of all the data updated.
   560      * Returns the signature bytes of all the data updated.
   536      * The format of the signature depends on the underlying
   561      * The format of the signature depends on the underlying