Source code: org/apache/derby/iapi/services/crypto/CipherFactory.java
1 /*
2
3 Derby - Class org.apache.derby.iapi.services.crypto.CipherFactory
4
5 Copyright 1998, 2004 The Apache Software Foundation or its licensors, as applicable.
6
7 Licensed under the Apache License, Version 2.0 (the "License");
8 you may not use this file except in compliance with the License.
9 You may obtain a copy of the License at
10
11 http://www.apache.org/licenses/LICENSE-2.0
12
13 Unless required by applicable law or agreed to in writing, software
14 distributed under the License is distributed on an "AS IS" BASIS,
15 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 See the License for the specific language governing permissions and
17 limitations under the License.
18
19 */
20
21 package org.apache.derby.iapi.services.crypto;
22
23 import org.apache.derby.iapi.error.StandardException;
24 import java.security.SecureRandom;
25 import java.util.Properties;
26 import org.apache.derby.io.StorageFactory;
27
28 /**
29 A CipherFactory can create new CipherProvider, which is a wrapper for a
30 javax.crypto.Cipher
31
32 This service is only available when run on JDK1.2 or beyond.
33 To use this service, either the SunJCE or an alternative clean room
34 implementation of the JCE must be installed.
35
36 To use a CipherProvider to encrypt or decrypt, it needs 3 things:
37 1) A CipherProvider that is initialized to ENCRYPT or DECRYPT
38 2) A secret Key for the encryption/decryption
39 3) An Initialization Vector (IvParameterSpec) that is used to create some
40 randomness in the encryption
41
42 See $WS/docs/funcspec/mulan/configurableEncryption.html
43
44 See http://java.sun.com/products/JDK/1.1/docs/guide/security/CryptoSpec.html
45 See http://java.sun.com/products/JDK/1.2/docs/guide/security/CryptoSpec.html
46 See http://java.sun.com/products/jdk/1.2/jce/index.html
47 */
48
49 public interface CipherFactory
50 {
51
52 /** Minimum bootPassword length */
53 public static final int MIN_BOOTPASS_LENGTH = 8;
54
55 /**
56 Get a CipherProvider that either Encrypts or Decrypts.
57 */
58 public static final int ENCRYPT = 1;
59 public static final int DECRYPT = 2;
60
61
62 SecureRandom getSecureRandom();
63
64 /**
65 Returns a CipherProvider which is the encryption or decryption engine.
66 @param mode is either ENCRYPT or DECRYPT. The CipherProvider can only
67 do encryption or decryption but not both.
68
69 @exception StandardException Standard Cloudscape Error Policy
70 */
71 CipherProvider createNewCipher(int mode)
72 throws StandardException;
73
74 public String changeBootPassword(String changeString, Properties properties, CipherProvider verify)
75 throws StandardException;
76
77 /**
78 Verify the external encryption key
79 @param create true means database is being created, whereas false
80 implies that the database has already been created
81 @param storageFactory storageFactory is used to access any stored data
82 that might be needed for verification process of the encryption key
83 @param properties properties at time of database connection as well as those in service.properties
84
85 @return throws exception if unable to verify that the encryption key is the same as that
86 used during database creation or if there are any problems when trying to do the
87 verification process
88 */
89 public void verifyKey(boolean create, StorageFactory storageFactory,Properties properties)
90 throws StandardException;
91
92 }
93
94