use of iaik.pkcs.pkcs11.parameters.RSAPkcsPssParameters in project X-Road by nordic-institute.
the class HardwareTokenWorker method createRsaPkcsPssMechanism.
private static Mechanism createRsaPkcsPssMechanism(long hashMechanism) {
Mechanism mechanism = Mechanism.get(PKCS11Constants.CKM_RSA_PKCS_PSS);
Mechanism hashAlgorithm = Mechanism.get(hashMechanism);
long maskGenerationFunction;
long saltLength;
if (hashMechanism == PKCS11Constants.CKM_SHA512) {
maskGenerationFunction = RSAPkcsPssParameters.MessageGenerationFunctionType.SHA512;
saltLength = CryptoUtils.SHA512_DIGEST_LENGTH;
} else if (hashMechanism == PKCS11Constants.CKM_SHA384) {
maskGenerationFunction = RSAPkcsPssParameters.MessageGenerationFunctionType.SHA384;
saltLength = CryptoUtils.SHA384_DIGEST_LENGTH;
} else if (hashMechanism == PKCS11Constants.CKM_SHA256) {
maskGenerationFunction = RSAPkcsPssParameters.MessageGenerationFunctionType.SHA256;
saltLength = CryptoUtils.SHA256_DIGEST_LENGTH;
} else {
throw new IllegalArgumentException("Not supported hash mechanism");
}
mechanism.setParameters(new RSAPkcsPssParameters(hashAlgorithm, maskGenerationFunction, saltLength));
return mechanism;
}
use of iaik.pkcs.pkcs11.parameters.RSAPkcsPssParameters in project xipki by xipki.
the class IaikP11SlotUtil method getMechanism.
// method digestKey0
static Mechanism getMechanism(long mechanism, P11Params parameters) throws P11TokenException {
Mechanism ret = Mechanism.get(mechanism);
if (parameters == null) {
return ret;
}
Parameters paramObj;
if (parameters instanceof P11Params.P11RSAPkcsPssParams) {
P11Params.P11RSAPkcsPssParams param = (P11Params.P11RSAPkcsPssParams) parameters;
paramObj = new RSAPkcsPssParameters(param.getHashAlgorithm(), param.getMaskGenerationFunction(), param.getSaltLength());
} else if (parameters instanceof P11Params.P11ByteArrayParams) {
paramObj = new OpaqueParameters(((P11Params.P11ByteArrayParams) parameters).getBytes());
} else if (parameters instanceof P11Params.P11IVParams) {
paramObj = new InitializationVectorParameters(((P11Params.P11IVParams) parameters).getIV());
} else {
throw new P11TokenException("unknown P11Parameters " + parameters.getClass().getName());
}
ret.setParameters(paramObj);
return ret;
}
Aggregations