private Asn1RSAPkcsPssParams(final ASN1Sequence seq) throws BadAsn1ObjectException { Asn1Util.requireRange(seq, 3, 3); int idx = 0; long contentHash = Asn1Util.getInteger(seq.getObjectAt(idx++)).longValue(); long mgfHash = Asn1Util.getInteger(seq.getObjectAt(idx++)).longValue(); int saltLength = Asn1Util.getInteger(seq.getObjectAt(idx++)).intValue(); this.pkcsPssParams = new P11RSAPkcsPssParams(contentHash, mgfHash, saltLength); } // constructor
@Override public ASN1Primitive toASN1Primitive() { ASN1EncodableVector vector = new ASN1EncodableVector(); vector.add(new ASN1Integer(pkcsPssParams.getHashAlgorithm())); vector.add(new ASN1Integer(pkcsPssParams.getMaskGenerationFunction())); vector.add(new ASN1Integer(pkcsPssParams.getSaltLength())); return new DERSequence(vector); }
private static Mechanism getMechanism(final long mechanism, final P11Params parameters) throws P11TokenException { Mechanism ret = Mechanism.get(mechanism); if (parameters == null) { return ret; } if (parameters instanceof P11RSAPkcsPssParams) { P11RSAPkcsPssParams param = (P11RSAPkcsPssParams) parameters; RSAPkcsPssParameters paramObj = new RSAPkcsPssParameters( Mechanism.get(param.hashAlgorithm()), param.maskGenerationFunction(), param.saltLength()); ret.setParameters(paramObj); } else { throw new P11TokenException("unknown P11Parameters " + parameters.getClass().getName()); } return ret; }
private Asn1RSAPkcsPssParams(ASN1Sequence seq) throws BadAsn1ObjectException { Asn1Util.requireRange(seq, 3, 3); int idx = 0; long contentHash = Asn1Util.getInteger(seq.getObjectAt(idx++)).longValue(); long mgfHash = Asn1Util.getInteger(seq.getObjectAt(idx++)).longValue(); int saltLength = Asn1Util.getInteger(seq.getObjectAt(idx++)).intValue(); this.pkcsPssParams = new P11RSAPkcsPssParams(contentHash, mgfHash, saltLength); } // constructor
@Override public ASN1Primitive toASN1Primitive() { ASN1EncodableVector vector = new ASN1EncodableVector(); vector.add(new ASN1Integer(pkcsPssParams.hashAlgorithm())); vector.add(new ASN1Integer(pkcsPssParams.maskGenerationFunction())); vector.add(new ASN1Integer(pkcsPssParams.saltLength())); return new DERSequence(vector); }
if (slot.supportsMechanism(PKCS11Constants.CKM_RSA_PKCS_PSS)) { this.mechanism = PKCS11Constants.CKM_RSA_PKCS_PSS; this.parameters = new P11RSAPkcsPssParams(asn1Params); Digest digest = hashAlgo.createDigest(); this.outputStream = new DigestOutputStream(digest); + PKCSObjectIdentifiers.id_RSASSA_PSS.getId() + " with " + hashAlgo); this.parameters = new P11RSAPkcsPssParams(asn1Params); this.outputStream = new ByteArrayOutputStream();
pssParam.hashAlgorithm()); if (contentHash == null) { throw new P11TokenException( "unsupported HashAlgorithm " + pssParam.hashAlgorithm()); } else if (hashAlgo != null && contentHash != hashAlgo) { throw new P11TokenException("Invalid parameters: invalid hash algorithm"); pssParam.maskGenerationFunction()); if (mgfHash == null) { throw new P11TokenException( "unsupported MaskGenerationFunction " + pssParam.hashAlgorithm()); try { encodedHashValue = SignerUtil.EMSA_PSS_ENCODE(contentHash, hashValue, mgfHash, (int) pssParam.saltLength(), signatureKeyBitLength(), random); } catch (XiSecurityException ex) { throw new P11TokenException("XiSecurityException: " + ex.getMessage(), ex);
if (slot.supportsMechanism(PKCS11Constants.CKM_RSA_PKCS_PSS)) { this.mechanism = PKCS11Constants.CKM_RSA_PKCS_PSS; this.parameters = new P11RSAPkcsPssParams(asn1Params); Digest digest = SignerUtil.getDigest(hashAlgo); this.outputStream = new DigestOutputStream(digest); this.parameters = new P11RSAPkcsPssParams(asn1Params); this.outputStream = new ByteArrayOutputStream();