java.lang.Object
org.seppiko.commons.utils.crypto.spec.ParameterSpacUtil
Parameter Specification implement util
- Author:
- Leonard Woo
-
Method Summary
Modifier and TypeMethodDescriptionstatic DHParameterSpecgetDH(BigInteger p, BigInteger g) DHParameterSpec objectstatic DHParameterSpecgetDH(BigInteger p, BigInteger g, int l) DHParameterSpec objectstatic ECParameterSpecgetEC(ECField field, BigInteger fristCoefficient, BigInteger secondfficient, BigInteger affineX, BigInteger affineY, BigInteger generator, int cofactor) static GCMParameterSpecgetGCM(int tLen, byte[] src) GCMParameterSpec objectstatic GCMParameterSpecgetGCM(int tLen, byte[] src, int off, int len) GCMParameterSpec objectstatic IvParameterSpecgetIV(byte[] iv) IvParameterSpec objectstatic IvParameterSpecgetIV(byte[] iv, int off, int len) IvParameterSpec objectstatic PBEParameterSpecgetPBE(byte[] salt, int iterationCount) PBEParameterSpec objectstatic PBEParameterSpecgetPBE(byte[] salt, int iterationCount, AlgorithmParameterSpec paramSpec) PBEParameterSpec object
-
Method Details
-
getGCM
public static GCMParameterSpec getGCM(int tLen, byte[] src) throws NullPointerException, IllegalArgumentException GCMParameterSpec object- Parameters:
tLen- GCM authentication tag lengthsrc- the IV source buffer- Returns:
- GCMParameterSpec object
- Throws:
NullPointerException- src is nullIllegalArgumentException- if tLen is negative, src is null, len or offset is negative, or the sum of offset and len is greater than the length of the src byte array.- See Also:
-
getGCM
public static GCMParameterSpec getGCM(int tLen, byte[] src, int off, int len) throws IllegalArgumentException GCMParameterSpec object- Parameters:
tLen- GCM authentication tag lengthsrc- the IV source bufferoff- the offset in src where the IV startslen- the number of IV bytes- Returns:
- GCMParameterSpec object
- Throws:
IllegalArgumentException- if tLen is negative, src is null, len or offset is negative, or the sum of offset and len is greater than the length of the src byte array.- See Also:
-
getIV
IvParameterSpec object- Parameters:
iv- the buffer with the IV- Returns:
- IvParameterSpec object
- Throws:
NullPointerException- if iv is nullIllegalArgumentException- if iv is null or (iv.length - offset < len)ArrayIndexOutOfBoundsException- is thrown if offset or len index bytes outside the iv.- See Also:
-
getIV
IvParameterSpec object- Parameters:
iv- the buffer with the IVoff- the offset in iv where the IV startslen- the number of IV bytes- Returns:
- IvParameterSpec object
- Throws:
IllegalArgumentException- if iv is null or (iv.length - offset < len)ArrayIndexOutOfBoundsException- is thrown if offset or len index bytes outside the iv.- See Also:
-
getPBE
PBEParameterSpec object- Parameters:
salt- the salt. The contents of salt are copied to protect against subsequent modification.iterationCount- the iteration count.- Returns:
- PBEParameterSpec object
- Throws:
NullPointerException- if salt is null- See Also:
-
getPBE
public static PBEParameterSpec getPBE(byte[] salt, int iterationCount, AlgorithmParameterSpec paramSpec) throws NullPointerException PBEParameterSpec object- Parameters:
salt- the salt. The contents of salt are copied to protect against subsequent modification.iterationCount- the iteration count.paramSpec- the cipher algorithm parameter specification- Returns:
- PBEParameterSpec object
- Throws:
NullPointerException- if salt is null- See Also:
-
getDH
DHParameterSpec object- Parameters:
p- the prime modulusg- the base generator- Returns:
- DHParameterSpec object
- See Also:
-
getDH
DHParameterSpec object- Parameters:
p- the prime modulusg- the base generatorl- the size in bits of the random exponent (private value)- Returns:
- DHParameterSpec object
- See Also:
-
getEC
public static ECParameterSpec getEC(ECField field, BigInteger fristCoefficient, BigInteger secondfficient, BigInteger affineX, BigInteger affineY, BigInteger generator, int cofactor) throws NullPointerException, IllegalArgumentException - Parameters:
field- the finite field that this elliptic curve is over.fristCoefficient- the first coefficient of this elliptic curve.secondfficient- the second coefficient of this elliptic curve.affineX- the affine x-coordinate.affineY- the affine y-coordinate.generator- the order of the generator.cofactor- the cofactor.- Returns:
- ECParameterSpec object
- Throws:
NullPointerException- if same parameter is nullIllegalArgumentException- ifgeneratororcofactoris not positive oraffineXoraffineYis not null and not infield.
-