aboutsummaryrefslogtreecommitdiffstats
path: root/libraries/spongycastle/jce/src/main/java/javax/crypto/spec/OAEPParameterSpec.java
blob: ccc5ad86ee4ccbdd01c36b21234cb4cfae7937c7 (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
99
100
101
102
103
package javax.crypto.spec;

import java.security.spec.AlgorithmParameterSpec;

/**
 * This class specifies the set of parameters used with OAEP Padding, as defined
 * in the PKCS #1 standard. Its ASN.1 definition in PKCS#1 standard is described
 * below:
 * 
 * </pre>
 * 
 * RSAES-OAEP-params ::= SEQUENCE { hashAlgorithm [0] OAEP-PSSDigestAlgorithms
 * DEFAULT sha1, maskGenAlgorithm [1] PKCS1MGFAlgorithms DEFAULT mgf1SHA1,
 * pSourceAlgorithm [2] PKCS1PSourceAlgorithms DEFAULT pSpecifiedEmpty }
 * 
 * </pre>
 * 
 * where
 * 
 * <pre>
 * 
 * OAEP-PSSDigestAlgorithms ALGORITHM-IDENTIFIER ::= { { OID id-sha1 PARAMETERS
 * NULL }| { OID id-sha256 PARAMETERS NULL }| { OID id-sha384 PARAMETERS NULL } | {
 * OID id-sha512 PARAMETERS NULL }, ... -- Allows for future expansion -- }
 * PKCS1MGFAlgorithms ALGORITHM-IDENTIFIER ::= { { OID id-mgf1 PARAMETERS
 * OAEP-PSSDigestAlgorithms }, ... -- Allows for future expansion -- }
 * PKCS1PSourceAlgorithms ALGORITHM-IDENTIFIER ::= { { OID id-pSpecified
 * PARAMETERS OCTET STRING }, ... -- Allows for future expansion -- }
 * 
 * </pre>
 * 
 * @see PSource
 */
public class OAEPParameterSpec
    implements AlgorithmParameterSpec
{
    private String mdName;
    private String mgfName;
    private AlgorithmParameterSpec mgfSpec;
    private PSource pSrc;

    /**
     * Constructs a parameter set for OAEP padding as defined in the PKCS #1
     * standard using the specified message digest algorithm mdName, mask
     * generation function algorithm mgfName, parameters for the mask generation
     * function mgfSpec, and source of the encoding input P pSrc.
     * 
     * @param mdName the algorithm name for the message digest.
     * @param mgfName the algorithm name for the mask generation function.
     * @param mgfSpec the parameters for the mask generation function. If null is
     *            specified, null will be returned by getMGFParameters().
     * @param pSrc the source of the encoding input P.
     * @throws NullPointerException  if mdName, mgfName, or pSrc is null.
     */
    public OAEPParameterSpec(String mdName, String mgfName,
            AlgorithmParameterSpec mgfSpec, PSource pSrc)
    {
        this.mdName = mdName;
        this.mgfName = mgfName;
        this.mgfSpec = mgfSpec;
        this.pSrc = pSrc;
    }

    /**
     * Returns the message digest algorithm name.
     * 
     * @return the message digest algorithm name.
     */
    public String getDigestAlgorithm()
    {
        return mdName;
    }

    /**
     * Returns the mask generation function algorithm name.
     * 
     * @return the mask generation function algorithm name.
     */
    public String getMGFAlgorithm()
    {
        return mgfName;
    }

    /**
     * Returns the parameters for the mask generation function.
     * 
     * @return the parameters for the mask generation function.
     */
    public AlgorithmParameterSpec getMGFParameters()
    {
        return mgfSpec;
    }

    /**
     * Returns the source of encoding input P.
     * 
     * @return the source of encoding input P.
     */
    public PSource getPSource()
    {
        return pSrc;
    }
}