if (!DigestFactory.isSameDigest(originalSpec.getDigestAlgorithm(), newParamSpec.getDigestAlgorithm())) { throw new InvalidParameterException("parameter must be using " + originalSpec.getDigestAlgorithm()); newParamSpec.getDigestAlgorithm())) { throw new InvalidParameterException( "digest algorithm for MGF should be the same as for PSS parameters.");
if (!DigestFactory.isSameDigest(originalSpec.getDigestAlgorithm(), newParamSpec.getDigestAlgorithm())) { throw new InvalidParameterException("parameter must be using " + originalSpec.getDigestAlgorithm()); newParamSpec.getDigestAlgorithm())) { throw new InvalidParameterException( "digest algorithm for MGF should be the same as for PSS parameters.");
if (!DigestFactory.isSameDigest(originalSpec.getDigestAlgorithm(), newParamSpec.getDigestAlgorithm())) throw new InvalidParameterException("parameter must be using " + originalSpec.getDigestAlgorithm()); if (!DigestFactory.isSameDigest(mgfParams.getDigestAlgorithm(), newParamSpec.getDigestAlgorithm()))
if (!DigestFactory.isSameDigest(originalSpec.getDigestAlgorithm(), newParamSpec.getDigestAlgorithm())) { throw new InvalidParameterException("parameter must be using " + originalSpec.getDigestAlgorithm()); newParamSpec.getDigestAlgorithm())) { throw new InvalidParameterException( "digest algorithm for MGF should be the same as for PSS parameters.");
if (!DigestFactory.isSameDigest(originalSpec.getDigestAlgorithm(), newParamSpec.getDigestAlgorithm())) throw new InvalidParameterException("parameter must be using " + originalSpec.getDigestAlgorithm()); if (!DigestFactory.isSameDigest(mgfParams.getDigestAlgorithm(), newParamSpec.getDigestAlgorithm()))
protected P11RSAPSSSignatureSpi(PSSParameterSpec baseParamSpec, boolean isRaw) { this.originalSpec = baseParamSpec; this.paramSpec = (baseParamSpec == null) ? PSSParameterSpec.DEFAULT : baseParamSpec; this.mgfDigest = DigestFactory.getDigest(paramSpec.getDigestAlgorithm()); this.saltLength = paramSpec.getSaltLength(); this.trailer = getTrailer(paramSpec.getTrailerField()); this.isRaw = isRaw; setupContentDigest(); }
protected P11RSAPSSSignatureSpi(final PSSParameterSpec baseParamSpec, final boolean isRaw) { this.originalSpec = baseParamSpec; this.paramSpec = (baseParamSpec == null) ? PSSParameterSpec.DEFAULT : baseParamSpec; this.mgfDigest = DigestFactory.getDigest(paramSpec.getDigestAlgorithm()); this.saltLength = paramSpec.getSaltLength(); this.trailer = getTrailer(paramSpec.getTrailerField()); this.isRaw = isRaw; setupContentDigest(); }
protected P11RSAPSSSignatureSpi(PSSParameterSpec baseParamSpec, boolean isRaw) { this.originalSpec = baseParamSpec; this.paramSpec = (baseParamSpec == null) ? PSSParameterSpec.DEFAULT : baseParamSpec; this.mgfDigest = DigestFactory.getDigest(paramSpec.getDigestAlgorithm()); this.saltLength = paramSpec.getSaltLength(); this.trailer = getTrailer(paramSpec.getTrailerField()); this.isRaw = isRaw; setupContentDigest(); }
protected PSSSignatureSpi( AsymmetricBlockCipher signer, PSSParameterSpec baseParamSpec, boolean isRaw) { this.signer = signer; this.originalSpec = baseParamSpec; if (baseParamSpec == null) { this.paramSpec = PSSParameterSpec.DEFAULT; } else { this.paramSpec = baseParamSpec; } this.mgfDigest = DigestFactory.getDigest(paramSpec.getDigestAlgorithm()); this.saltLength = paramSpec.getSaltLength(); this.trailer = getTrailer(paramSpec.getTrailerField()); this.isRaw = isRaw; setupContentDigest(); }
protected PSSSignatureSpi( AsymmetricBlockCipher signer, PSSParameterSpec baseParamSpec, boolean isRaw) { this.signer = signer; this.originalSpec = baseParamSpec; if (baseParamSpec == null) { this.paramSpec = PSSParameterSpec.DEFAULT; } else { this.paramSpec = baseParamSpec; } this.mgfDigest = DigestFactory.getDigest(paramSpec.getDigestAlgorithm()); this.saltLength = paramSpec.getSaltLength(); this.trailer = getTrailer(paramSpec.getTrailerField()); this.isRaw = isRaw; setupContentDigest(); }
protected PSSSignatureSpi( AsymmetricBlockCipher signer, PSSParameterSpec baseParamSpec, boolean isRaw) { this.signer = signer; this.originalSpec = baseParamSpec; if (baseParamSpec == null) { this.paramSpec = PSSParameterSpec.DEFAULT; } else { this.paramSpec = baseParamSpec; } this.mgfDigest = DigestFactory.getDigest(paramSpec.getDigestAlgorithm()); this.saltLength = paramSpec.getSaltLength(); this.trailer = getTrailer(paramSpec.getTrailerField()); this.isRaw = isRaw; setupContentDigest(); }
protected PSSSignatureSpi( AsymmetricBlockCipher signer, PSSParameterSpec baseParamSpec, boolean isRaw) { this.signer = signer; this.originalSpec = baseParamSpec; if (baseParamSpec == null) { this.paramSpec = PSSParameterSpec.DEFAULT; } else { this.paramSpec = baseParamSpec; } this.mgfDigest = DigestFactory.getDigest(paramSpec.getDigestAlgorithm()); this.saltLength = paramSpec.getSaltLength(); this.trailer = getTrailer(paramSpec.getTrailerField()); this.isRaw = isRaw; setupContentDigest(); }
/** * Return the PKCS#1 ASN.1 structure RSASSA-PSS-params. */ protected byte[] engineGetEncoded() throws IOException { PSSParameterSpec pssSpec = currentSpec; AlgorithmIdentifier hashAlgorithm = new AlgorithmIdentifier( DigestFactory.getOID(pssSpec.getDigestAlgorithm()), DERNull.INSTANCE); MGF1ParameterSpec mgfSpec = (MGF1ParameterSpec)pssSpec.getMGFParameters(); AlgorithmIdentifier maskGenAlgorithm = new AlgorithmIdentifier( PKCSObjectIdentifiers.id_mgf1, new AlgorithmIdentifier(DigestFactory.getOID(mgfSpec.getDigestAlgorithm()), DERNull.INSTANCE)); RSASSAPSSparams pssP = new RSASSAPSSparams(hashAlgorithm, maskGenAlgorithm, new ASN1Integer(pssSpec.getSaltLength()), new ASN1Integer(pssSpec.getTrailerField())); return pssP.getEncoded("DER"); }
/** * Return the PKCS#1 ASN.1 structure RSASSA-PSS-params. */ protected byte[] engineGetEncoded() throws IOException { PSSParameterSpec pssSpec = currentSpec; AlgorithmIdentifier hashAlgorithm = new AlgorithmIdentifier( DigestFactory.getOID(pssSpec.getDigestAlgorithm()), DERNull.INSTANCE); MGF1ParameterSpec mgfSpec = (MGF1ParameterSpec)pssSpec.getMGFParameters(); AlgorithmIdentifier maskGenAlgorithm = new AlgorithmIdentifier( PKCSObjectIdentifiers.id_mgf1, new AlgorithmIdentifier(DigestFactory.getOID(mgfSpec.getDigestAlgorithm()), DERNull.INSTANCE)); RSASSAPSSparams pssP = new RSASSAPSSparams(hashAlgorithm, maskGenAlgorithm, new ASN1Integer(pssSpec.getSaltLength()), new ASN1Integer(pssSpec.getTrailerField())); return pssP.getEncoded("DER"); }
/** * Return the PKCS#1 ASN.1 structure RSASSA-PSS-params. */ protected byte[] engineGetEncoded() throws IOException { PSSParameterSpec pssSpec = currentSpec; AlgorithmIdentifier hashAlgorithm = new AlgorithmIdentifier( DigestFactory.getOID(pssSpec.getDigestAlgorithm()), DERNull.INSTANCE); MGF1ParameterSpec mgfSpec = (MGF1ParameterSpec)pssSpec.getMGFParameters(); AlgorithmIdentifier maskGenAlgorithm = new AlgorithmIdentifier( PKCSObjectIdentifiers.id_mgf1, new AlgorithmIdentifier(DigestFactory.getOID(mgfSpec.getDigestAlgorithm()), DERNull.INSTANCE)); RSASSAPSSparams pssP = new RSASSAPSSparams(hashAlgorithm, maskGenAlgorithm, new ASN1Integer(pssSpec.getSaltLength()), new ASN1Integer(pssSpec.getTrailerField())); return pssP.getEncoded("DER"); }
/** * Return the PKCS#1 ASN.1 structure RSASSA-PSS-params. */ protected byte[] engineGetEncoded() throws IOException { PSSParameterSpec pssSpec = currentSpec; AlgorithmIdentifier hashAlgorithm = new AlgorithmIdentifier( DigestFactory.getOID(pssSpec.getDigestAlgorithm()), DERNull.INSTANCE); MGF1ParameterSpec mgfSpec = (MGF1ParameterSpec)pssSpec.getMGFParameters(); AlgorithmIdentifier maskGenAlgorithm = new AlgorithmIdentifier( PKCSObjectIdentifiers.id_mgf1, new AlgorithmIdentifier(DigestFactory.getOID(mgfSpec.getDigestAlgorithm()), DERNull.INSTANCE)); RSASSAPSSparams pssP = new RSASSAPSSparams(hashAlgorithm, maskGenAlgorithm, new ASN1Integer(pssSpec.getSaltLength()), new ASN1Integer(pssSpec.getTrailerField())); return pssP.getEncoded("DER"); }
/** * Return the PKCS#1 ASN.1 structure RSASSA-PSS-params. */ protected byte[] engineGetEncoded() throws IOException { PSSParameterSpec pssSpec = currentSpec; AlgorithmIdentifier hashAlgorithm = new AlgorithmIdentifier( DigestFactory.getOID(pssSpec.getDigestAlgorithm()), DERNull.INSTANCE); MGF1ParameterSpec mgfSpec = (MGF1ParameterSpec)pssSpec.getMGFParameters(); AlgorithmIdentifier maskGenAlgorithm = new AlgorithmIdentifier( PKCSObjectIdentifiers.id_mgf1, new AlgorithmIdentifier(DigestFactory.getOID(mgfSpec.getDigestAlgorithm()), DERNull.INSTANCE)); RSASSAPSSparams pssP = new RSASSAPSSparams(hashAlgorithm, maskGenAlgorithm, new ASN1Integer(pssSpec.getSaltLength()), new ASN1Integer(pssSpec.getTrailerField())); return pssP.getEncoded("DER"); }
@Override protected byte[] engineGetEncoded() throws IOException { long cbbRef = 0; long seqRef = 0; try { cbbRef = NativeCrypto.asn1_write_init(); seqRef = NativeCrypto.asn1_write_sequence(cbbRef); OAEPParameters.writeHashAndMgfHash(seqRef, spec.getDigestAlgorithm(), (MGF1ParameterSpec) spec.getMGFParameters()); // Implementations are prohibited from writing the default value for any of the fields if (spec.getSaltLength() != 20) { long tagRef = 0; try { tagRef = NativeCrypto.asn1_write_tag(seqRef, 2); NativeCrypto.asn1_write_uint64(tagRef, spec.getSaltLength()); } finally { NativeCrypto.asn1_write_flush(seqRef); NativeCrypto.asn1_write_free(tagRef); } } // 1 is the only legal value for trailerField and the default, so ignore it return NativeCrypto.asn1_write_finish(cbbRef); } catch (IOException e) { NativeCrypto.asn1_write_cleanup(cbbRef); throw e; } finally { NativeCrypto.asn1_write_free(seqRef); NativeCrypto.asn1_write_free(cbbRef); } }
@Override protected byte[] engineGetEncoded() throws IOException { long cbbRef = 0; long seqRef = 0; try { cbbRef = NativeCrypto.asn1_write_init(); seqRef = NativeCrypto.asn1_write_sequence(cbbRef); OAEPParameters.writeHashAndMgfHash(seqRef, spec.getDigestAlgorithm(), (MGF1ParameterSpec) spec.getMGFParameters()); // Implementations are prohibited from writing the default value for any of the fields if (spec.getSaltLength() != 20) { long tagRef = 0; try { tagRef = NativeCrypto.asn1_write_tag(seqRef, 2); NativeCrypto.asn1_write_uint64(tagRef, spec.getSaltLength()); } finally { NativeCrypto.asn1_write_flush(seqRef); NativeCrypto.asn1_write_free(tagRef); } } // 1 is the only legal value for trailerField and the default, so ignore it return NativeCrypto.asn1_write_finish(cbbRef); } catch (IOException e) { NativeCrypto.asn1_write_cleanup(cbbRef); throw e; } finally { NativeCrypto.asn1_write_free(seqRef); NativeCrypto.asn1_write_free(cbbRef); } }
/** * Return the PKCS#1 ASN.1 structure RSASSA-PSS-params. */ protected byte[] engineGetEncoded() throws IOException { PSSParameterSpec pssSpec = currentSpec; AlgorithmIdentifier hashAlgorithm = new AlgorithmIdentifier( DigestFactory.getOID(pssSpec.getDigestAlgorithm()), new DERNull()); MGF1ParameterSpec mgfSpec = (MGF1ParameterSpec)pssSpec.getMGFParameters(); AlgorithmIdentifier maskGenAlgorithm = new AlgorithmIdentifier( PKCSObjectIdentifiers.id_mgf1, new AlgorithmIdentifier(DigestFactory.getOID(mgfSpec.getDigestAlgorithm()), new DERNull())); RSASSAPSSparams pssP = new RSASSAPSSparams(hashAlgorithm, maskGenAlgorithm, new ASN1Integer(pssSpec.getSaltLength()), new ASN1Integer(pssSpec.getTrailerField())); return pssP.getEncoded("DER"); }