1. Project Clover database Tue Dec 20 2016 21:24:09 CET
  2. Package org.xwiki.crypto.signer.params

File PssSignerParameters.java

 

Coverage histogram

../../../../../img/srcFileCovDistChart7.png
64% of files have more coverage

Code metrics

0
10
6
1
107
38
6
0.6
1.67
6
1

Classes

Class Line # Actions
PssSignerParameters 31 10 0% 6 6
0.62562.5%
 

Contributing tests

This file is covered by 8 tests. .

Source view

1    /*
2    * See the NOTICE file distributed with this work for additional
3    * information regarding copyright ownership.
4    *
5    * This is free software; you can redistribute it and/or modify it
6    * under the terms of the GNU Lesser General Public License as
7    * published by the Free Software Foundation; either version 2.1 of
8    * the License, or (at your option) any later version.
9    *
10    * This software is distributed in the hope that it will be useful,
11    * but WITHOUT ANY WARRANTY; without even the implied warranty of
12    * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13    * Lesser General Public License for more details.
14    *
15    * You should have received a copy of the GNU Lesser General Public
16    * License along with this software; if not, write to the Free
17    * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
18    * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
19    */
20    package org.xwiki.crypto.signer.params;
21   
22    import org.xwiki.crypto.params.cipher.asymmetric.AsymmetricCipherParameters;
23    import org.xwiki.crypto.params.cipher.asymmetric.AsymmetricKeyParameters;
24   
25    /**
26    * PSS signer parameters.
27    *
28    * @version $Id: b550ba0118c4f9b5e4bcc36821292796b17f8895 $
29    * @since 5.4RC1
30    */
 
31    public class PssSignerParameters implements AsymmetricCipherParameters
32    {
33    private final AsymmetricKeyParameters keyParams;
34   
35    private final PssParameters pssParams;
36   
37    /**
38    * Construct default RSASSA-PSS parameters according to PKCS #1 definition of default value.
39    *
40    * @param keyParams the key to use for the RSA cipher.
41    */
 
42  0 toggle public PssSignerParameters(AsymmetricKeyParameters keyParams)
43    {
44  0 this.keyParams = keyParams;
45  0 this.pssParams = new PssParameters();
46    }
47   
48    /**
49    * Construct RSASSA-PSS parameters using default trailer and the same digest algorithm for both hash and mgf1.
50    *
51    * @param keyParams the key to use for the RSA cipher.
52    * @param hashAlgorithm digest algorithm to use for hash and mgf1.
53    * @param saltLength size of salt in bytes.
54    */
 
55  12 toggle public PssSignerParameters(AsymmetricKeyParameters keyParams, String hashAlgorithm, int saltLength)
56    {
57  12 this.keyParams = keyParams;
58  12 this.pssParams = new PssParameters(hashAlgorithm, saltLength);
59    }
60   
61    /**
62    * Construct RSASSA-PSS parameters using custom parameters.
63    *
64    * @param keyParams the key to use for the RSA cipher.
65    * @param hashAlgorithm digest algorithm to use for hash.
66    * @param maskGenAlgorithm digest algorithm to use for mgf1.
67    * @param saltLength size of salt in bytes.
68    */
 
69  0 toggle public PssSignerParameters(AsymmetricKeyParameters keyParams, String hashAlgorithm, String maskGenAlgorithm,
70    int saltLength)
71    {
72  0 this.keyParams = keyParams;
73  0 this.pssParams = new PssParameters(hashAlgorithm, maskGenAlgorithm, saltLength);
74    }
75   
76    /**
77    * Construct RSASSA-PSS parameters using custom parameters.
78    *
79    * @param keyParams the key to use for the RSA cipher.
80    * @param hashAlgorithm digest algorithm to use for hash.
81    * @param maskGenAlgorithm digest algorithm to use for mgf1.
82    * @param saltLength size of salt in bytes.
83    * @param trailerField trailer selection, only valid value is 1.
84    */
 
85  4 toggle public PssSignerParameters(AsymmetricKeyParameters keyParams, String hashAlgorithm, String maskGenAlgorithm,
86    int saltLength, int trailerField)
87    {
88  4 this.keyParams = keyParams;
89  4 this.pssParams = new PssParameters(hashAlgorithm, maskGenAlgorithm, saltLength, trailerField);
90    }
91   
92    /**
93    * @return the key paramaters.
94    */
 
95  16 toggle public AsymmetricKeyParameters getKeyParameters()
96    {
97  16 return this.keyParams;
98    }
99   
100    /**
101    * @return the PSS parameters.
102    */
 
103  32 toggle public PssParameters getPssParameters()
104    {
105  32 return this.pssParams;
106    }
107    }