/** * 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; }
private int validateIterationCount(BigInteger i) { int count = i.intValue(); if (count < 0) { throw new IllegalStateException("negative iteration count found"); } BigInteger maxValue = Properties.asBigInteger(PKCS12_MAX_IT_COUNT_PROPERTY); if (maxValue != null) { if (maxValue.intValue() < count) { throw new IllegalStateException("iteration count " + count + " greater than " + maxValue.intValue()); } } return count; }
public static BigInteger asBigInteger(String propertyName) { String p = fetchProperty(propertyName); if (p != null) { return new BigInteger(p); } return null; }
public ESTResponse(ESTRequest originalRequest, Source source) throws IOException { this.originalRequest = originalRequest; this.source = source; if (source instanceof LimitedSource) { this.absoluteReadLimit = ((LimitedSource)source).getAbsoluteReadLimit(); } Set<String> opts = Properties.asKeySet("org.spongycastle.debug.est"); if (opts.contains("input") || opts.contains("all")) { this.inputStream = new PrintingInputStream(source.getInputStream()); } else { this.inputStream = source.getInputStream(); } this.headers = new HttpUtil.Headers(); this.lineBuffer = new byte[1024]; process(); }
Set<String> opts = Properties.asKeySet("org.spongycastle.debug.est"); if (opts.contains("output") || opts.contains("all"))
/** * 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; }
public static Set<String> asKeySet(String propertyName) { Set<String> set = new HashSet<String>(); String p = fetchProperty(propertyName); if (p != null) { StringTokenizer sTok = new StringTokenizer(p, ","); while (sTok.hasMoreElements()) { set.add(Strings.toLowerCase(sTok.nextToken()).trim()); } } return Collections.unmodifiableSet(set); }
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; }
/** * Return whether a particular override has been set to true. * * @param propertyName the property name for the override. * @return true if the property is set to "true", false otherwise. */ public static boolean isOverrideSet(String propertyName) { try { String p = fetchProperty(propertyName); if (p != null) { return "true".equals(Strings.toLowerCase(p)); } return false; } catch (AccessControlException e) { return false; } }
/** * 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"))