| 1 |
|
|
| 2 |
|
|
| 3 |
|
|
| 4 |
|
|
| 5 |
|
|
| 6 |
|
|
| 7 |
|
|
| 8 |
|
|
| 9 |
|
|
| 10 |
|
|
| 11 |
|
|
| 12 |
|
|
| 13 |
|
|
| 14 |
|
|
| 15 |
|
|
| 16 |
|
|
| 17 |
|
|
| 18 |
|
|
| 19 |
|
|
| 20 |
|
package org.xwiki.crypto.password.internal.pbe; |
| 21 |
|
|
| 22 |
|
import java.io.FilterInputStream; |
| 23 |
|
import java.io.FilterOutputStream; |
| 24 |
|
import java.io.InputStream; |
| 25 |
|
import java.io.OutputStream; |
| 26 |
|
import java.security.GeneralSecurityException; |
| 27 |
|
|
| 28 |
|
import org.xwiki.crypto.cipher.Cipher; |
| 29 |
|
import org.xwiki.crypto.params.cipher.symmetric.SymmetricCipherParameters; |
| 30 |
|
import org.xwiki.crypto.password.KeyDerivationFunction; |
| 31 |
|
import org.xwiki.crypto.password.PasswordBasedCipher; |
| 32 |
|
|
| 33 |
|
|
| 34 |
|
|
| 35 |
|
|
| 36 |
|
|
| 37 |
|
|
| 38 |
|
@version |
| 39 |
|
@since |
| 40 |
|
|
| |
|
| 33.3% |
Uncovered Elements: 20 (30) |
Complexity: 14 |
Complexity Density: 0.88 |
|
| 41 |
|
public abstract class AbstractPBCipher implements PasswordBasedCipher |
| 42 |
|
{ |
| 43 |
|
private KeyDerivationFunction kdf; |
| 44 |
|
|
| 45 |
|
private SymmetricCipherParameters parameters; |
| 46 |
|
|
| 47 |
|
private Cipher cipher; |
| 48 |
|
|
| 49 |
|
|
| 50 |
|
|
| 51 |
|
|
| 52 |
|
@param |
| 53 |
|
@param |
| 54 |
|
@param |
| 55 |
|
|
| |
|
| 100% |
Uncovered Elements: 0 (3) |
Complexity: 1 |
Complexity Density: 0.33 |
|
| 56 |
26 |
public AbstractPBCipher(Cipher cipher, KeyDerivationFunction kdf, SymmetricCipherParameters parameters)... |
| 57 |
|
{ |
| 58 |
26 |
this.cipher = cipher; |
| 59 |
26 |
this.kdf = kdf; |
| 60 |
26 |
this.parameters = parameters; |
| 61 |
|
} |
| 62 |
|
|
| |
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 63 |
50 |
@Override... |
| 64 |
|
public KeyDerivationFunction getKeyDerivationFunction() |
| 65 |
|
{ |
| 66 |
50 |
return this.kdf; |
| 67 |
|
} |
| 68 |
|
|
| |
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 69 |
25 |
@Override... |
| 70 |
|
public SymmetricCipherParameters getParameters() |
| 71 |
|
{ |
| 72 |
25 |
return this.parameters; |
| 73 |
|
} |
| 74 |
|
|
| |
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 75 |
0 |
@Override... |
| 76 |
|
public String getAlgorithmName() |
| 77 |
|
{ |
| 78 |
0 |
return this.cipher.getAlgorithmName(); |
| 79 |
|
} |
| 80 |
|
|
| |
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 81 |
0 |
@Override... |
| 82 |
|
public int getInputBlockSize() |
| 83 |
|
{ |
| 84 |
0 |
return this.cipher.getInputBlockSize(); |
| 85 |
|
} |
| 86 |
|
|
| |
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 87 |
0 |
@Override... |
| 88 |
|
public int getOutputBlockSize() |
| 89 |
|
{ |
| 90 |
0 |
return this.cipher.getOutputBlockSize(); |
| 91 |
|
} |
| 92 |
|
|
| |
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 93 |
0 |
@Override... |
| 94 |
|
public FilterInputStream getInputStream(InputStream is) |
| 95 |
|
{ |
| 96 |
0 |
return this.cipher.getInputStream(is); |
| 97 |
|
} |
| 98 |
|
|
| |
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 99 |
0 |
@Override... |
| 100 |
|
public FilterOutputStream getOutputStream(OutputStream os) |
| 101 |
|
{ |
| 102 |
0 |
return this.cipher.getOutputStream(os); |
| 103 |
|
} |
| 104 |
|
|
| |
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 105 |
0 |
@Override... |
| 106 |
|
public boolean isForEncryption() |
| 107 |
|
{ |
| 108 |
0 |
return this.cipher.isForEncryption(); |
| 109 |
|
} |
| 110 |
|
|
| |
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 111 |
0 |
@Override... |
| 112 |
|
public byte[] update(byte[] input) |
| 113 |
|
{ |
| 114 |
0 |
return this.cipher.update(input); |
| 115 |
|
} |
| 116 |
|
|
| |
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 117 |
0 |
@Override... |
| 118 |
|
public byte[] update(byte[] input, int inputOffset, int inputLen) |
| 119 |
|
{ |
| 120 |
0 |
return this.cipher.update(input, inputOffset, inputLen); |
| 121 |
|
} |
| 122 |
|
|
| |
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 123 |
0 |
@Override... |
| 124 |
|
public byte[] doFinal() throws GeneralSecurityException |
| 125 |
|
{ |
| 126 |
0 |
return this.cipher.doFinal(); |
| 127 |
|
} |
| 128 |
|
|
| |
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 129 |
26 |
@Override... |
| 130 |
|
public byte[] doFinal(byte[] input) throws GeneralSecurityException |
| 131 |
|
{ |
| 132 |
26 |
return this.cipher.doFinal(input); |
| 133 |
|
} |
| 134 |
|
|
| |
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 135 |
0 |
@Override... |
| 136 |
|
public byte[] doFinal(byte[] input, int inputOffset, int inputLen) throws GeneralSecurityException |
| 137 |
|
{ |
| 138 |
0 |
return this.cipher.doFinal(input, inputOffset, inputLen); |
| 139 |
|
} |
| 140 |
|
} |