1 /* |
1 /* |
2 * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved. |
2 * Copyright (c) 2014, 2015, 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 |
53 // public implementation classes |
53 // public implementation classes |
54 public static final class AesEcbNoPadding extends NativeCipher { |
54 public static final class AesEcbNoPadding extends NativeCipher { |
55 public AesEcbNoPadding() throws NoSuchAlgorithmException { |
55 public AesEcbNoPadding() throws NoSuchAlgorithmException { |
56 super(UcryptoMech.CRYPTO_AES_ECB); |
56 super(UcryptoMech.CRYPTO_AES_ECB); |
57 } |
57 } |
|
58 public AesEcbNoPadding(int keySize) throws NoSuchAlgorithmException { |
|
59 super(UcryptoMech.CRYPTO_AES_ECB, keySize); |
|
60 } |
58 } |
61 } |
59 public static final class AesCbcNoPadding extends NativeCipher { |
62 public static final class AesCbcNoPadding extends NativeCipher { |
60 public AesCbcNoPadding() throws NoSuchAlgorithmException { |
63 public AesCbcNoPadding() throws NoSuchAlgorithmException { |
61 super(UcryptoMech.CRYPTO_AES_CBC); |
64 super(UcryptoMech.CRYPTO_AES_CBC); |
62 } |
65 } |
|
66 public AesCbcNoPadding(int keySize) throws NoSuchAlgorithmException { |
|
67 super(UcryptoMech.CRYPTO_AES_CBC, keySize); |
|
68 } |
63 } |
69 } |
64 public static final class AesCtrNoPadding extends NativeCipher { |
70 public static final class AesCtrNoPadding extends NativeCipher { |
65 public AesCtrNoPadding() throws NoSuchAlgorithmException { |
71 public AesCtrNoPadding() throws NoSuchAlgorithmException { |
66 super(UcryptoMech.CRYPTO_AES_CTR); |
72 super(UcryptoMech.CRYPTO_AES_CTR); |
67 } |
73 } |
68 } |
74 } |
69 public static final class AesCfb128NoPadding extends NativeCipher { |
75 public static final class AesCfb128NoPadding extends NativeCipher { |
70 public AesCfb128NoPadding() throws NoSuchAlgorithmException { |
76 public AesCfb128NoPadding() throws NoSuchAlgorithmException { |
71 super(UcryptoMech.CRYPTO_AES_CFB128); |
77 super(UcryptoMech.CRYPTO_AES_CFB128); |
72 } |
|
73 } |
|
74 |
|
75 // public implementation classes with fixed key sizes |
|
76 public static final class Aes128EcbNoPadding extends NativeCipher { |
|
77 public Aes128EcbNoPadding() throws NoSuchAlgorithmException { |
|
78 super(UcryptoMech.CRYPTO_AES_ECB, 16); |
|
79 } |
|
80 } |
|
81 public static final class Aes128CbcNoPadding extends NativeCipher { |
|
82 public Aes128CbcNoPadding() throws NoSuchAlgorithmException { |
|
83 super(UcryptoMech.CRYPTO_AES_CBC, 16); |
|
84 } |
|
85 } |
|
86 public static final class Aes192EcbNoPadding extends NativeCipher { |
|
87 public Aes192EcbNoPadding() throws NoSuchAlgorithmException { |
|
88 super(UcryptoMech.CRYPTO_AES_ECB, 24); |
|
89 } |
|
90 } |
|
91 public static final class Aes192CbcNoPadding extends NativeCipher { |
|
92 public Aes192CbcNoPadding() throws NoSuchAlgorithmException { |
|
93 super(UcryptoMech.CRYPTO_AES_CBC, 24); |
|
94 } |
|
95 } |
|
96 public static final class Aes256EcbNoPadding extends NativeCipher { |
|
97 public Aes256EcbNoPadding() throws NoSuchAlgorithmException { |
|
98 super(UcryptoMech.CRYPTO_AES_ECB, 32); |
|
99 } |
|
100 } |
|
101 public static final class Aes256CbcNoPadding extends NativeCipher { |
|
102 public Aes256CbcNoPadding() throws NoSuchAlgorithmException { |
|
103 super(UcryptoMech.CRYPTO_AES_CBC, 32); |
|
104 } |
78 } |
105 } |
79 } |
106 |
80 |
107 // ok as constants since AES is all we support |
81 // ok as constants since AES is all we support |
108 public static final int AES_BLOCK_SIZE = 16; |
82 public static final int AES_BLOCK_SIZE = 16; |