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

File AsymmetricKeyWithIVParameters.java

 

Coverage histogram

../../../../../../img/srcFileCovDistChart0.png
83% of files have more coverage

Code metrics

0
8
5
1
91
31
5
0.62
1.6
5
1

Classes

Class Line # Actions
AsymmetricKeyWithIVParameters 32 8 0% 5 13
0.00%
 

Contributing tests

No tests hitting this source file were found.

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.cipher.asymmetric;
21   
22    import java.security.SecureRandom;
23   
24    import org.bouncycastle.crypto.params.AsymmetricKeyParameter;
25   
26    /**
27    * Asymmetric cipher parameters for cipher requiring a key and an initialization vector.
28    *
29    * @version $Id: 01568d89f54f5252ceb272278644034204d48cc6 $
30    * @since 5.4M1
31    */
 
32    public class AsymmetricKeyWithIVParameters implements AsymmetricCipherParameters
33    {
34    /** A encryption initialization vector. */
35    private final AsymmetricKeyParameter keyParam;
36   
37    private final byte[] iv;
38   
39    /**
40    * Initialize parameters.
41    *
42    * @param key the key.
43    * @param iv the initialization vector.
44    */
 
45  0 toggle public AsymmetricKeyWithIVParameters(AsymmetricKeyParameter key, byte[] iv)
46    {
47  0 this.keyParam = key;
48  0 this.iv = iv;
49    }
50   
51    /**
52    * Initialize parameters with a random initialization vector.
53    *
54    * @param key the key.
55    * @param ivSize the size of the initialization vector to randomize using a new default SecureRandom.
56    */
 
57  0 toggle public AsymmetricKeyWithIVParameters(AsymmetricKeyParameter key, int ivSize)
58    {
59  0 this(key, ivSize, new SecureRandom());
60    }
61   
62    /**
63    * Initialize parameters with a random initialization vector.
64    *
65    * @param key the key.
66    * @param ivSize the size of the initialization vector to randomize.
67    * @param random the random source.
68    */
 
69  0 toggle public AsymmetricKeyWithIVParameters(AsymmetricKeyParameter key, int ivSize, SecureRandom random)
70    {
71  0 this.keyParam = key;
72  0 this.iv = new byte[ivSize];
73  0 random.nextBytes(this.iv);
74    }
75   
76    /**
77    * @return the initialization vector.
78    */
 
79  0 toggle public AsymmetricKeyParameter getKeyParameters()
80    {
81  0 return this.keyParam;
82    }
83   
84    /**
85    * @return the initialization vector.
86    */
 
87  0 toggle public byte[] getIV()
88    {
89  0 return this.iv;
90    }
91    }