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

File RSAKeyGenerationParameters.java

 

Coverage histogram

../../../../../../img/srcFileCovDistChart10.png
0% of files have more coverage

Code metrics

0
9
7
1
130
42
7
0.78
1.29
7
1

Classes

Class Line # Actions
RSAKeyGenerationParameters 33 9 0% 7 0
1.0100%
 

Contributing tests

This file is covered by 4 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.params.generator.asymmetric;
21   
22    import java.math.BigInteger;
23   
24    import org.xwiki.crypto.params.generator.KeyGenerationParameters;
25    import org.xwiki.crypto.params.generator.symmetric.GenericKeyGenerationParameters;
26   
27    /**
28    * Parameters for RSA key pair generation.
29    *
30    * @version $Id: cc7d2e2a2ec2e5738db8fc94ae15dfc8bb40e615 $
31    * @since 5.4M1
32    */
 
33    public class RSAKeyGenerationParameters extends GenericKeyGenerationParameters implements KeyGenerationParameters
34    {
35    /** Default value for the public exponent. */
36    private static final BigInteger DEFAULT_PUBLIC_EXPONENT = BigInteger.valueOf(0x10001);
37   
38    /** Default certainty value for prime evaluation. */
39    private static final int DEFAULT_CERTAINTY = 12;
40   
41    /** Default key strength. */
42    private static final int DEFAULT_STRENGTH = 256;
43   
44    /** Current public exponent. */
45    private final BigInteger publicExponent;
46   
47    /** Current certainty for prime evaluation. */
48    private final int certainty;
49   
50    /**
51    * Build a new instance with all defaults.
52    *
53    * The default key strength is {@value #DEFAULT_STRENGTH} bytes.
54    * The default public exponent is 0x10001.
55    * The default certainty for prime evaluation is {@value #DEFAULT_CERTAINTY}.
56    */
 
57  2 toggle public RSAKeyGenerationParameters()
58    {
59  2 this(DEFAULT_STRENGTH);
60    }
61   
62    /**
63    * Build a new instance with the given strength.
64    *
65    * The default public exponent is 0x10001.
66    * The default certainty for prime evaluation is {@value #DEFAULT_CERTAINTY}.
67    *
68    * @param strength the strength in bytes.
69    */
 
70  4 toggle public RSAKeyGenerationParameters(int strength)
71    {
72  4 this(strength, DEFAULT_PUBLIC_EXPONENT, DEFAULT_CERTAINTY);
73    }
74   
75    /**
76    * Build a new instance with the given strength and public exponent.
77    *
78    * The default certainty for prime evaluation is {@value #DEFAULT_CERTAINTY}.
79    *
80    * @param strength the key strength in bytes.
81    * @param publicExponent the public exponent.
82    */
 
83  1 toggle public RSAKeyGenerationParameters(int strength, BigInteger publicExponent)
84    {
85  1 this(strength, publicExponent, DEFAULT_CERTAINTY);
86    }
87   
88    /**
89    * Build a new instance with the given strength and certainty for prime evaluation.
90    *
91    * The default public exponent is 0x10001.
92    *
93    * @param strength the key strength in bytes.
94    * @param certainty certainty for prime evaluation.
95    */
 
96  1 toggle public RSAKeyGenerationParameters(int strength, int certainty)
97    {
98  1 this(strength, DEFAULT_PUBLIC_EXPONENT, certainty);
99    }
100   
101    /**
102    * Build a new instance with all custom parameters.
103    *
104    * @param strength the key strength in bytes.
105    * @param publicExponent the public exponent.
106    * @param certainty certainty for prime evaluation.
107    */
 
108  6 toggle public RSAKeyGenerationParameters(int strength, BigInteger publicExponent, int certainty)
109    {
110  6 super(strength);
111  6 this.publicExponent = publicExponent;
112  6 this.certainty = certainty;
113    }
114   
115    /**
116    * @return the public exponent.
117    */
 
118  6 toggle public BigInteger getPublicExponent()
119    {
120  6 return this.publicExponent;
121    }
122   
123    /**
124    * @return the certainty for prime evaluation.
125    */
 
126  6 toggle public int getCertainty()
127    {
128  6 return this.certainty;
129    }
130    }