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

File BcRc5b128CbcPaddedCipherFactory.java

 

Coverage histogram

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

Code metrics

2
5
3
1
71
35
4
0.8
1.67
3
1.33

Classes

Class Line # Actions
BcRc5b128CbcPaddedCipherFactory 45 5 0% 4 10
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.cipher.internal.symmetric.factory;
21   
22    import javax.inject.Named;
23    import javax.inject.Singleton;
24   
25    import org.bouncycastle.crypto.BlockCipher;
26    import org.bouncycastle.crypto.engines.RC564Engine;
27    import org.bouncycastle.crypto.params.RC5Parameters;
28    import org.xwiki.component.annotation.Component;
29    import org.xwiki.crypto.params.cipher.symmetric.KeyParameter;
30    import org.xwiki.crypto.params.cipher.symmetric.RC5KeyParameters;
31   
32    /**
33    * Cipher factory for the RC5 Cipher with a 128bits block size.
34    *
35    * WARNING: RC5 is protected by U.S. Patents 5,724,428 and 5,835,600. Therefore, before expiration of these patents,
36    * the usage of this algorithm is subject to restricted usage on the US territories.
37    * RC5 is a trademark of RSA Security Inc.
38    *
39    * @version $Id: 325fa32db09d27ef0f48a7095e55b19e9e4cdd6f $
40    * @since 5.4M1
41    */
42    @Component
43    @Singleton
44    @Named("RC5-64/CBC/PKCS7Padding")
 
45    public class BcRc5b128CbcPaddedCipherFactory extends AbstractBcCbcPaddedCipherFactory
46    {
47    /** Supported key sizes for this Cipher. RC5 support any size up to 256 bytes, but we limit multiple of 64bits. */
48    private static final int[] KEY_SIZES = newKeySizeArray(0, 256, 8);
49   
 
50  0 toggle @Override
51    protected org.bouncycastle.crypto.CipherParameters getBcKeyParameter(KeyParameter parameter)
52    {
53  0 if (parameter instanceof RC5KeyParameters) {
54  0 return new RC5Parameters(parameter.getKey(), ((RC5KeyParameters) parameter).getRounds());
55    } else {
56  0 return new org.bouncycastle.crypto.params.KeyParameter(parameter.getKey());
57    }
58    }
59   
 
60  0 toggle @Override
61    protected BlockCipher getEngineInstance()
62    {
63  0 return new RC564Engine();
64    }
65   
 
66  0 toggle @Override
67    public int[] getSupportedKeySizes()
68    {
69  0 return KEY_SIZES;
70    }
71    }