< prev index next >

jdk/src/jdk.crypto.ucrypto/solaris/classes/com/oracle/security/ucrypto/GCMParameters.java

Print this page




  31 import java.security.spec.AlgorithmParameterSpec;
  32 import java.security.spec.InvalidParameterSpecException;
  33 import javax.crypto.spec.GCMParameterSpec;
  34 import sun.security.util.*;
  35 
  36 /**
  37  * This class implements the parameter set used with GCM mode
  38  * which is defined in RFC5084 as follows:
  39  *
  40  * <pre>
  41  * GCMParameters ::= SEQUENCE {
  42  *   aes-nonce        OCTET STRING, -- recommended size is 12 octets
  43  *   aes-ICVlen       AES-GCM-ICVlen DEFAULT 12 }
  44  *
  45  * where
  46  * AES-GCM-ICVlen ::= INTEGER (12 | 13 | 14 | 15 | 16)
  47  * NOTE: however, NIST 800-38D also lists 4 (32bit) and 8 (64bit)
  48  * as possible AES-GCM-ICVlen values, so we allow all 6 values.
  49  * </pre>
  50  *
  51  * @since 1.9
  52  */
  53 public final class GCMParameters extends AlgorithmParametersSpi {
  54 
  55     private byte[] iv; // i.e. aes-nonce
  56     private int tLen; // i.e. aes-ICVlen, in bytes
  57 
  58     public GCMParameters() {}
  59 
  60     private void setValues(byte[] iv, int tLen) throws IOException {
  61         if (iv == null) {
  62             throw new IOException("IV cannot be null");
  63         }
  64         if (tLen != 4 && tLen != 8 && (tLen < 12 || tLen > 16)) {
  65             throw new IOException("Unsupported tag length: " + tLen);
  66         }
  67         this.iv = iv;
  68         this.tLen = tLen;
  69     }
  70 
  71     protected byte[] engineGetEncoded() throws IOException {




  31 import java.security.spec.AlgorithmParameterSpec;
  32 import java.security.spec.InvalidParameterSpecException;
  33 import javax.crypto.spec.GCMParameterSpec;
  34 import sun.security.util.*;
  35 
  36 /**
  37  * This class implements the parameter set used with GCM mode
  38  * which is defined in RFC5084 as follows:
  39  *
  40  * <pre>
  41  * GCMParameters ::= SEQUENCE {
  42  *   aes-nonce        OCTET STRING, -- recommended size is 12 octets
  43  *   aes-ICVlen       AES-GCM-ICVlen DEFAULT 12 }
  44  *
  45  * where
  46  * AES-GCM-ICVlen ::= INTEGER (12 | 13 | 14 | 15 | 16)
  47  * NOTE: however, NIST 800-38D also lists 4 (32bit) and 8 (64bit)
  48  * as possible AES-GCM-ICVlen values, so we allow all 6 values.
  49  * </pre>
  50  *
  51  * @since 9
  52  */
  53 public final class GCMParameters extends AlgorithmParametersSpi {
  54 
  55     private byte[] iv; // i.e. aes-nonce
  56     private int tLen; // i.e. aes-ICVlen, in bytes
  57 
  58     public GCMParameters() {}
  59 
  60     private void setValues(byte[] iv, int tLen) throws IOException {
  61         if (iv == null) {
  62             throw new IOException("IV cannot be null");
  63         }
  64         if (tLen != 4 && tLen != 8 && (tLen < 12 || tLen > 16)) {
  65             throw new IOException("Unsupported tag length: " + tLen);
  66         }
  67         this.iv = iv;
  68         this.tLen = tLen;
  69     }
  70 
  71     protected byte[] engineGetEncoded() throws IOException {


< prev index next >