blob: 03016e1f2db3648fa8aa3ce0c8f2a2d8fe895851 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
|
package javax.crypto.spec;
/**
* This class specifies the source for encoding input P in OAEP Padding, as
* defined in the {@link http://www.ietf.org/rfc/rfc3447.txt PKCS #1} standard.
*
* <pre>
*
* PKCS1PSourceAlgorithms ALGORITHM-IDENTIFIER ::= {
* { OID id-pSpecified PARAMETERS OCTET STRING },
* ... -- Allows for future expansion --
* }
* </pre>
*/
public class PSource
{
/**
* This class is used to explicitly specify the value for encoding input P
* in OAEP Padding.
*
*/
public final static class PSpecified
extends PSource
{
private byte[] p;
/**
* The encoding input P whose value equals byte[0].
*/
public static final PSpecified DEFAULT = new PSpecified(new byte[0]);
/**
* Constructs the source explicitly with the specified value p as the
* encoding input P.
*
* @param p the value of the encoding input. The contents of the array
* are copied to protect against subsequent modification.
* @throws NullPointerException if p is null.
*/
public PSpecified(byte[] p)
{
super("PSpecified");
if (p == null)
{
throw new NullPointerException("The encoding input is null");
}
this.p = copyOf(p);
}
/**
* Returns the value of encoding input P.
*
* @return the value of encoding input P. A new array is returned each
* time this method is called.
*/
public byte[] getValue()
{
return copyOf(p);
}
private byte[] copyOf(byte[] b)
{
byte[] tmp = new byte[b.length];
System.arraycopy(b, 0, tmp, 0, b.length);
return tmp;
}
}
private String pSrcName;
/**
* Constructs a source of the encoding input P for OAEP padding as defined
* in the PKCS #1 standard using the specified PSource algorithm.
*
* @param pSrcName the algorithm for the source of the encoding input P.
* @throws NullPointerException if pSrcName is null.
*/
protected PSource(String pSrcName)
{
if (pSrcName == null)
{
throw new NullPointerException("pSrcName is null");
}
this.pSrcName = pSrcName;
}
/**
* Returns the PSource algorithm name.
*
* @return the PSource algorithm name.
*/
public String getAlgorithm()
{
return pSrcName;
}
}
|