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

File BcRc5b64CbcPaddedCipherFactory.java

 

Coverage histogram

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

Code metrics

2
5
3
1
70
34
4
0.8
1.67
3
1.33

Classes

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