/** * Enable the specified override property for the current thread only. * * @param propertyName the property name for the override. * @param enable true if the override should be enabled, false if it should be disabled. * @return true if the override was already set, false otherwise. */ public static boolean setThreadOverride(String propertyName, boolean enable) { boolean isSet = isOverrideSet(propertyName); Map localProps = (Map)threadProperties.get(); if (localProps == null) { localProps = new HashMap(); } localProps.put(propertyName, enable ? "true" : "false"); threadProperties.set(localProps); return isSet; }
/** * Enable the specified override property in the current thread only. * * @param propertyName the property name for the override. * @return true if the override set true in thread local, false otherwise. */ public static boolean removeThreadOverride(String propertyName) { boolean isSet = isOverrideSet(propertyName); Map localProps = (Map)threadProperties.get(); if (localProps == null) { return false; } localProps.remove(propertyName); if (localProps.isEmpty()) { threadProperties.remove(); } else { threadProperties.set(localProps); } return isSet; }
ASN1Integer(byte[] bytes, boolean clone) { // Apply loose validation, see note in public constructor ANS1Integer(byte[]) if (!Properties.isOverrideSet("org.spongycastle.asn1.allow_unsafe_integer")) { if (isMalformed(bytes)) { throw new IllegalArgumentException("malformed integer"); } } this.bytes = (clone) ? Arrays.clone(bytes) : bytes; }
/** * Constructor from encoded BigInteger. * * @param bytes the value of this enumerated as an encoded BigInteger (signed). */ public ASN1Enumerated( byte[] bytes) { if (!Properties.isOverrideSet("org.spongycastle.asn1.allow_unsafe_integer")) { if (ASN1Integer.isMalformed(bytes)) { throw new IllegalArgumentException("malformed enumerated"); } } this.bytes = Arrays.clone(bytes); }
public BigInteger calculateAgreement(CipherParameters pubKey) { if (Properties.isOverrideSet("org.spongycastle.ec.disable_mqv")) { throw new IllegalStateException("ECMQV explicitly disabled"); } MQVPublicParameters pubParams = (MQVPublicParameters)pubKey; ECPrivateKeyParameters staticPrivateKey = privParams.getStaticPrivateKey(); ECDomainParameters parameters = staticPrivateKey.getParameters(); if (!parameters.equals(pubParams.getStaticPublicKey().getParameters())) { throw new IllegalStateException("ECMQV public key components have wrong domain parameters"); } ECPoint agreement = calculateMqvAgreement(parameters, staticPrivateKey, privParams.getEphemeralPrivateKey(), privParams.getEphemeralPublicKey(), pubParams.getStaticPublicKey(), pubParams.getEphemeralPublicKey()).normalize(); if (agreement.isInfinity()) { throw new IllegalStateException("Infinity is not a valid agreement value for MQV"); } return agreement.getAffineXCoord().toBigInteger(); }
if (Properties.isOverrideSet("org.spongycastle.dsa.FIPS186-2for1024bits"))
registerOidAlgorithmParameters(provider, SECObjectIdentifiers.dhSinglePass_cofactorDH_sha512kdf_scheme, "EC"); if (!Properties.isOverrideSet("org.spongycastle.ec.disable_mqv"))