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

File AbstractBcCbcPaddedCipherFactory.java

 
testCipherWithWrongParameters: Invalid parameters for cipher: org.xwiki.crypto.cipher.in...
testCipherWithAsymmetricParameters: Unexpected parameters received for a symmetric cipher: or...
testCipherWithWrongParameters: Invalid parameters for cipher: org.xwiki.crypto.cipher.in...
testCipherWithAsymmetricParameters: Unexpected parameters received for a symmetric cipher: or...
testCipherWithWrongParameters: Invalid parameters for cipher: org.xwiki.crypto.cipher.in...
testCipherWithAsymmetricParameters: Unexpected parameters received for a symmetric cipher: or...
testCipherWithAsymmetricParameters: Unexpected parameters received for a symmetric cipher: or...
testCipherWithWrongParameters: Invalid parameters for cipher: org.xwiki.crypto.cipher.in...
testCipherWithAsymmetricParameters: Unexpected parameters received for a symmetric cipher: or...
testCipherWithWrongParameters: Invalid parameters for cipher: org.xwiki.crypto.cipher.in...
testCipherWithWrongParameters: Invalid parameters for cipher: org.xwiki.crypto.cipher.in...
testCipherWithWrongParameters: Invalid parameters for cipher: org.xwiki.crypto.cipher.in...
testCipherWithAsymmetricParameters: Unexpected parameters received for a symmetric cipher: or...
testCipherWithAsymmetricParameters: Unexpected parameters received for a symmetric cipher: or...
 

Coverage histogram

../../../../../../../img/srcFileCovDistChart8.png
54% of files have more coverage

Code metrics

4
8
3
1
68
38
5
0.62
2.67
3
1.67

Classes

Class Line # Actions
AbstractBcCbcPaddedCipherFactory 37 8 0% 5 4
0.7333333573.3%
 

Contributing tests

This file is covered by 36 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.cipher.internal.symmetric.factory;
21   
22    import org.bouncycastle.crypto.BlockCipher;
23    import org.bouncycastle.crypto.modes.CBCBlockCipher;
24    import org.bouncycastle.crypto.params.ParametersWithIV;
25    import org.xwiki.crypto.cipher.SymmetricCipher;
26    import org.xwiki.crypto.cipher.internal.symmetric.BcPaddedSymmetricCipher;
27    import org.xwiki.crypto.params.cipher.CipherParameters;
28    import org.xwiki.crypto.params.cipher.symmetric.KeyWithIVParameters;
29    import org.xwiki.crypto.params.cipher.symmetric.SymmetricCipherParameters;
30   
31    /**
32    * Abstract base class for a Cipher Factory of CBC padded Bouncy Castle cipher.
33    *
34    * @version $Id: 8a62c7c954dd9f3846812f5a6dfc60a98ca84a93 $
35    * @since 5.4M1
36    */
 
37    Test failure here public abstract class AbstractBcCbcPaddedCipherFactory extends AbstractBcSymmetricCipherFactory
38    {
 
39  50 toggle private ParametersWithIV toParametersWithIV(SymmetricCipherParameters parameters)
40    {
41  43 if (!(parameters instanceof KeyWithIVParameters)) {
42  0 Test failure here throw new IllegalArgumentException("Invalid parameters for cipher: " + parameters.getClass().getName());
43    }
44  43 KeyWithIVParameters params = (KeyWithIVParameters) parameters;
45   
46  43 return new ParametersWithIV(
47    getBcKeyParameter(params.getKeyParameter()),
48    params.getIV()
49    );
50    }
51   
 
52  50 toggle @Override
53    protected BlockCipher getCipherInstance(boolean forEncryption, SymmetricCipherParameters parameters)
54    {
55  50 return new CBCBlockCipher(getEngineInstance());
56    }
57   
 
58  57 toggle @Override
59    public SymmetricCipher getInstance(boolean forEncryption, CipherParameters parameters)
60    {
61  50 if (!(parameters instanceof SymmetricCipherParameters)) {
62  0 throw new IllegalArgumentException("Unexpected parameters received for a symmetric cipher: "
63    Test failure here + parameters.getClass().getName());
64    }
65  50 return new BcPaddedSymmetricCipher(getCipherInstance(forEncryption, (SymmetricCipherParameters) parameters),
66    Test failure here forEncryption, toParametersWithIV((SymmetricCipherParameters) parameters));
67    }
68    }