Lines Matching refs:key

31  * This class specifies a DES key.
40 * The constant which defines the length of a DES key in bytes.
44 private byte[] key;
50 * each is both a key and a dual giving 12 keys with duals. The last
117 * <code>key</code> as the key material for the DES key.
119 * <p> The bytes that constitute the DES key are those between
120 * <code>key[0]</code> and <code>key[7]</code> inclusive.
122 * @param key the buffer with the DES key material. The first 8 bytes
125 * @exception NullPointerException if the given key material is
127 * @exception InvalidKeyException if the given key material is shorter
130 public DESKeySpec(byte[] key) throws InvalidKeyException {
131 this(key, 0);
136 * <code>key</code>, beginning at <code>offset</code> inclusive,
137 * as the key material for the DES key.
139 * <p> The bytes that constitute the DES key are those between
140 * <code>key[offset]</code> and <code>key[offset+7]</code> inclusive.
142 * @param key the buffer with the DES key material. The first 8 bytes
145 * @param offset the offset in <code>key</code>, where the DES key
148 * @exception NullPointerException if the given key material is
150 * @exception InvalidKeyException if the given key material, starting at
153 public DESKeySpec(byte[] key, int offset) throws InvalidKeyException {
154 if (key.length - offset < DES_KEY_LEN) {
155 throw new InvalidKeyException("Wrong key size");
157 this.key = new byte[DES_KEY_LEN];
158 System.arraycopy(key, offset, this.key, 0, DES_KEY_LEN);
162 * Returns the DES key material.
164 * @return the DES key material. Returns a new array
168 return (byte[])this.key.clone();
172 * Checks if the given DES key material, starting at <code>offset</code>
175 * @param key the buffer with the DES key material.
176 * @param offset the offset in <code>key</code>, where the DES key
179 * @return true if the given DES key material is parity-adjusted, false
182 * @exception InvalidKeyException if the given key material is
186 public static boolean isParityAdjusted(byte[] key, int offset)
188 if (key == null) {
189 throw new InvalidKeyException("null key");
191 if (key.length - offset < DES_KEY_LEN) {
192 throw new InvalidKeyException("Wrong key size");
196 int k = Integer.bitCount(key[offset++] & 0xff);
206 * Checks if the given DES key material is weak or semi-weak.
208 * @param key the buffer with the DES key material.
209 * @param offset the offset in <code>key</code>, where the DES key
212 * @return true if the given DES key material is weak or semi-weak, false
215 * @exception InvalidKeyException if the given key material is
219 public static boolean isWeak(byte[] key, int offset)
221 if (key == null) {
222 throw new InvalidKeyException("null key");
224 if (key.length - offset < DES_KEY_LEN) {
225 throw new InvalidKeyException("Wrong key size");
230 if (WEAK_KEYS[i][j] != key[j+offset]) {