KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > snmp4j > security > PrivacyProtocol


1 /*_############################################################################
2   _##
3   _## SNMP4J - PrivacyProtocol.java
4   _##
5   _## Copyright 2003-2007 Frank Fock and Jochen Katz (SNMP4J.org)
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
22
23 package org.snmp4j.security;
24
25 import org.snmp4j.smi.OID;
26
27 /**
28  * The <code>PrivacyProtocol</code> interface defines a common
29  * interface for all SNMP privacy protocols.
30  *
31  * @author Jochen Katz & Frank Fock
32  * @version 1.0
33  */

34 public interface PrivacyProtocol extends SecurityProtocol {
35
36   /**
37    * Encrypts a message using a given encryption key, engine boots count, and
38    * engine ID.
39    *
40    * @param unencryptedData
41    * the unencrypted data. This byte array may contain leading and trailing
42    * bytes that will not be encrypted.
43    * @param offset
44    * the offset into the <code>unencryptedData</code> where to start
45    * encryption.
46    * @param length
47    * the length of the substring starting at <code>offset</code> to encrypt.
48    * @param encryptionKey
49    * the key to be used for encryption.
50    * @param engineBoots
51    * the engine boots counter to use.
52    * @param engineTime
53    * the engine time to use.
54    * @param decryptParams
55    * returns the decryption parameters needed to decrypt the data that
56    * has been encrypted by this method.
57    * @return
58    * the encrypted copy of <code>unencryptedData</code>.
59    */

60   byte[] encrypt(byte[] unencryptedData,
61                  int offset,
62                  int length,
63                  byte[] encryptionKey,
64                  long engineBoots,
65                  long engineTime,
66                  DecryptParams decryptParams);
67
68   /**
69    * Decrypts a message using a given decryption key, engine boots count, and
70    * engine ID.
71    *
72    * @param cryptedData
73    * the crypted data. This byte array may contain leading and trailing
74    * bytes that will not be decrypted.
75    * @param offset
76    * the offset into the <code>cryptedData</code> where to start
77    * encryption.
78    * @param length
79    * the length of the substring starting at <code>offset</code> to decrypt.
80    * @param decryptionKey
81    * the key to be used for decryption.
82    * @param engineBoots
83    * the engine boots counter to use.
84    * @param engineTime
85    * the engine time to use.
86    * @param decryptParams
87    * contains the decryption parameters.
88    * @return
89    * the decrypted data, or <code>null</code> if decryption failed.
90    */

91   byte[] decrypt(byte[] cryptedData,
92                  int offset,
93                  int length,
94                  byte[] decryptionKey,
95                  long engineBoots,
96                  long engineTime,
97                  DecryptParams decryptParams);
98
99   /**
100    * Gets the OID uniquely identifying the privacy protocol.
101    * @return
102    * an <code>OID</code> instance.
103    */

104   OID getID();
105
106   /**
107    * Gets the length of a scoped PDU when encrypted with this security protocol.
108    * @param scopedPDULength
109    * the length of the (unencrypted) scoped PDU.
110    * @return
111    * the length of the encrypted scoped PDU.
112    */

113   int getEncryptedLength(int scopedPDULength);
114
115   /**
116    * Gets the minimum key size for this privacy protcol.
117    * @return
118    * the minimum key size for this privacy protcol.
119    */

120   int getMinKeyLength();
121
122   /**
123    * Gets the maximum key size for this privacy protcol.
124    * @return
125    * the minimum key size for this privacy protcol.
126    */

127   int getMaxKeyLength();
128
129   /**
130    * Gets the length of the decryption parameters used by this security
131    * protocol.
132    * @return
133    * a positive integer denoting the length of decryption parameters returned
134    * by this security protocol.
135    */

136   int getDecryptParamsLength();
137 }
138
139
Popular Tags