1 /*
2 * Title: S/MIME Project
3 * Description: S/MIME email sending capabilities
4 * @Author Vladimir Radisic
5 * @Version 2.0.1
6 */
7
8
9 package org.webdocwf.util.smime.cms;
10
11
12 import org.webdocwf.util.smime.exception.SMIMEException;
13 import org.webdocwf.util.smime.der.DERSequencePr;
14 import org.webdocwf.util.smime.der.DERInteger;
15 import org.webdocwf.util.smime.der.DEROctetString;
16
17
18 /***
19 * RC2CBCParameter is parameter used in Content Encryption Algorithm Identifier
20 * in CMS object for encrypted message, for RC2_CBC algorithms. Parameter for
21 * this algorithm is made from initialization vector and key length in bits.<BR>
22 * <BR>
23 * <DL>
24 * RC2CBCParameter ::= SEQUENCE {<BR>
25 * <DD> rc2ParameterVersion INTEGER,<BR>
26 * <DD> iv OCTET STRING }<BR>
27 * </DL>
28 * <BR>
29 * rc2ParameterVersion ::= INTEGER<BR>
30 * <BR>
31 * IV ::= OCTET STRING -- exactly 8 octets<BR>
32 */
33 public class RC2CBCParameter extends DERSequencePr {
34
35 /***
36 * Constructor takes key length in bits and IV (Initialization Vector) as byte
37 * array
38 * @param lenKey0 key length
39 * @param iv0 Initialization Vector
40 * @exception SMIMEException if Initialization Vector - IV is not 8 bytes long
41 * or key size is not 40, 64 or 128. Also, exception could be thrown in
42 * super class constructor or in super class addContent method.
43 */
44 public RC2CBCParameter(int lenKey0, byte[] iv0) throws SMIMEException {
45 int version;
46
47 if (lenKey0 == 40)
48 version = 160;
49 else if (lenKey0 == 64)
50 version = 120;
51 else if (lenKey0 == 128)
52 version = 58;
53 else
54 throw new SMIMEException(this, 1014);
55 super.addContent(new DERInteger(version).getDEREncoded());
56 if (iv0.length != 8)
57 throw new SMIMEException(this, 1012);
58 super.addContent(new DEROctetString(iv0).getDEREncoded());
59 }
60 }
61
This page was automatically generated by Maven