KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > javax > crypto > spec > DESKeySpec


1 /*
2  * @(#)DESKeySpec.java 1.9 04/01/14
3  *
4  * Copyright (c) 2004 Sun Microsystems, Inc. All Rights Reserved.
5  * SUN PROPRIETARY/CONFIDENTIAL. Use is subject to license terms.
6  */

7   
8 /*
9  * NOTE:
10  * Because of various external restrictions (i.e. US export
11  * regulations, etc.), the actual source code can not be provided
12  * at this time. This file represents the skeleton of the source
13  * file, so that javadocs of the API can be created.
14  */

15
16 package javax.crypto.spec;
17
18 import java.security.InvalidKeyException;
19
20 /**
21  * This class specifies a DES key.
22  *
23  * @author Jan Luehe
24  *
25  * @version 1.21, 01/07/04
26  * @since 1.4
27  */

28 public class DESKeySpec implements java.security.spec.KeySpec
29 {
30     /**
31      * The constant which defines the length of a DES key in bytes.
32      */

33     public static final int DES_KEY_LEN = 8;
34
35     /**
36      * Creates a DESKeySpec object using the first 8 bytes in
37      * <code>key</code> as the key material for the DES key.
38      *
39      * <p> The bytes that constitute the DES key are those between
40      * <code>key[0]</code> and <code>key[7]</code> inclusive.
41      *
42      * @param key the buffer with the DES key material. The first 8 bytes
43      * of the buffer are copied to protect against subsequent modification.
44      *
45      * @exception NullPointerException if the given key material is
46      * <code>null</code>
47      * @exception InvalidKeyException if the given key material is shorter
48      * than 8 bytes.
49      */

50     public DESKeySpec(byte[] key) throws InvalidKeyException { }
51
52     /**
53      * Creates a DESKeySpec object using the first 8 bytes in
54      * <code>key</code>, beginning at <code>offset</code> inclusive,
55      * as the key material for the DES key.
56      *
57      * <p> The bytes that constitute the DES key are those between
58      * <code>key[offset]</code> and <code>key[offset+7]</code> inclusive.
59      *
60      * @param key the buffer with the DES key material. The first 8 bytes
61      * of the buffer beginning at <code>offset</code> inclusive are copied
62      * to protect against subsequent modification.
63      * @param offset the offset in <code>key</code>, where the DES key
64      * material starts.
65      *
66      * @exception NullPointerException if the given key material is
67      * <code>null</code>
68      * @exception InvalidKeyException if the given key material, starting at
69      * <code>offset</code> inclusive, is shorter than 8 bytes.
70      */

71     public DESKeySpec(byte[] key, int offset) throws InvalidKeyException { }
72
73     /**
74      * Returns the DES key material.
75      *
76      * @return the DES key material. Returns a new array
77      * each time this method is called.
78      */

79     public byte[] getKey() { }
80
81     /**
82      * Checks if the given DES key material, starting at <code>offset</code>
83      * inclusive, is parity-adjusted.
84      *
85      * @param key the buffer with the DES key material.
86      * @param offset the offset in <code>key</code>, where the DES key
87      * material starts.
88      *
89      * @return true if the given DES key material is parity-adjusted, false
90      * otherwise.
91      *
92      * @exception InvalidKeyException if the given key material is
93      * <code>null</code>, or starting at <code>offset</code> inclusive, is
94      * shorter than 8 bytes.
95      */

96     public static boolean isParityAdjusted(byte[] key, int offset)
97         throws InvalidKeyException
98     { }
99
100     /**
101      * Checks if the given DES key material is weak or semi-weak.
102      *
103      * @param key the buffer with the DES key material.
104      * @param offset the offset in <code>key</code>, where the DES key
105      * material starts.
106      *
107      * @return true if the given DES key material is weak or semi-weak, false
108      * otherwise.
109      *
110      * @exception InvalidKeyException if the given key material is
111      * <code>null</code>, or starting at <code>offset</code> inclusive, is
112      * shorter than 8 bytes.
113      */

114     public static boolean isWeak(byte[] key, int offset)
115         throws InvalidKeyException
116     { }
117 }
118
Popular Tags