Top Description Inners Fields Constructors Methods
org.bouncycastle.crypto

public final Class CryptoServicesRegistrar

extends Object
Class Inheritance
Imports
java.math.BigInteger, java.security.AccessController, .Permission, .PrivilegedAction, .SecureRandom, java.util.Collections, .HashMap, .Map, java.util.concurrent.atomic.AtomicReference, java.util.logging.Logger, org.bouncycastle.asn1.x9.X9ECParameters, org.bouncycastle.crypto.params.DHParameters, .DHValidationParameters, .DSAParameters, .DSAValidationParameters, org.bouncycastle.util.Properties, .Strings, org.bouncycastle.util.encoders.Hex

Basic registrar class for providing defaults for cryptography services in this module.

Nested and Inner Type Summary

Modifier and TypeClass and Description
public static class
CryptoServicesRegistrar.Property

Available properties that can be set.

private static class

Field Summary

Modifier and TypeField and Description
private static final Permission
private static final Permission
private static final Permission
private static final Permission
private static final SecureRandomProvider
private static final AtomicReference<SecureRandomProvider>
private static final Map<String, Object[]>
private static final Logger
private static final CryptoServicesConstraints
private static final boolean
private static final AtomicReference<CryptoServicesConstraints>
private static final ThreadLocal<Map<String, Object[]>>

Constructor Summary

AccessConstructor and Description
private

Method Summary

Modifier and TypeMethod and Description
public static void
checkConstraints(CryptoServiceProperties
the service to be checked.
cryptoService
)

Check a service to make sure it meets the current constraints.

private static void
checkPermission(final Permission permission)

private static int
chooseLowerBound(int pSize)

public static <
the base type of the property value
T
>
T[]

Returns:

an array of T if a value was previously set, null otherwise.
clearGlobalProperty
(CryptoServicesRegistrar.Property
the property to be cleared.
property
)

Clear the global value for the passed in property.

public static <
the base type of the property value
T
>
T[]

Returns:

an array of T if a value was previously set, null otherwise.
clearThreadProperty
(CryptoServicesRegistrar.Property
the property to be cleared.
property
)

Clear the thread local value for the passed in property.

private static CryptoServicesConstraints
public static <
the type to be returned
T
>
T

Returns:

null if the property is not set, the default value otherwise,
getProperty
(CryptoServicesRegistrar.Property
the property to look up.
property
)

Return the default value for a particular property if one exists.

public static SecureRandom

Returns:

the default SecureRandom
getSecureRandom
()

Return the default source of randomness.

public static SecureRandom

Returns:

the SecureRandom parameter if it is not null, or else the default SecureRandom
getSecureRandom
(SecureRandom
the SecureRandom to use if it is not null.
secureRandom
)

Return either the passed-in SecureRandom, or if it is null, then the default source of randomness.

public static CryptoServicesConstraints

Returns:

the algorithm/services constraints.
getServicesConstraints
()

Return the current algorithm/services constraints.

public static <
the base type of the array to be returned.
T
>
T[]

Returns:

null if the property is not set, an array of the current values otherwise.
getSizedProperty
(CryptoServicesRegistrar.Property
the name of the property to look up.
property
)

Return an array representing the current values for a sized property such as DH_DEFAULT_PARAMS or DSA_DEFAULT_PARAMS.

public static <
the type of the value to be returned.
T
>
T

Returns:

the current value for the size, null if there is no value set,
getSizedProperty
(CryptoServicesRegistrar.Property
the name of the property to look up.
property
,
int
the size (in bits) of the defining value in the property type.
size
)

Return the value for a specific size for a sized property such as DH_DEFAULT_PARAMS or DSA_DEFAULT_PARAMS.

private static Object[]
private static <T> void
private static <T> void
localSetThread(CryptoServicesRegistrar.Property property, T[] propertyValue)

private static Object[]
public static <
the base type of the property value.
T
>
void
setGlobalProperty(CryptoServicesRegistrar.Property
the name of the property to set.
property
,
T...
the values to assign to the property.
propertyValue
)

Set the value of the the passed in property globally in the JVM.

public static void
setSecureRandom(final SecureRandom
the SecureRandom to use as the default.
secureRandom
)

Set a default secure random to be used where none is otherwise provided.

public static void
setSecureRandomProvider(SecureRandomProvider
a provider SecureRandom to use when a default SecureRandom is requested.
secureRandomProvider
)

Set a default secure random provider to be used where none is otherwise provided.

public static void
setServicesConstraints(CryptoServicesConstraints constraints)

Set the current algorithm constraints.

public static <
the base type of the property value.
T
>
void
setThreadProperty(CryptoServicesRegistrar.Property
the name of the property to set.
property
,
T...
the values to assign to the property.
propertyValue
)

Set the value of the the passed in property on the current thread only.

private static DHParameters
toDH(DSAParameters dsaParams)

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

CanSetConstraintsback to summary
private static final Permission CanSetConstraints
CanSetDefaultPropertyback to summary
private static final Permission CanSetDefaultProperty
CanSetDefaultRandomback to summary
private static final Permission CanSetDefaultRandom
CanSetThreadPropertyback to summary
private static final Permission CanSetThreadProperty
defaultRandomProviderImplback to summary
private static final SecureRandomProvider defaultRandomProviderImpl
defaultSecureRandomProviderback to summary
private static final AtomicReference<SecureRandomProvider> defaultSecureRandomProvider
globalPropertiesback to summary
private static final Map<String, Object[]> globalProperties
LOGback to summary
private static final Logger LOG
noConstraintsImplback to summary
private static final CryptoServicesConstraints noConstraintsImpl
preconfiguredConstraintsback to summary
private static final boolean preconfiguredConstraints
servicesConstraintsback to summary
private static final AtomicReference<CryptoServicesConstraints> servicesConstraints
threadPropertiesback to summary
private static final ThreadLocal<Map<String, Object[]>> threadProperties

Constructor Detail

CryptoServicesRegistrarback to summary
private CryptoServicesRegistrar()

Method Detail

checkConstraintsback to summary
public static void checkConstraints(CryptoServiceProperties cryptoService)

Check a service to make sure it meets the current constraints.

Parameters
cryptoService:CryptoServiceProperties

the service to be checked.

Exceptions
CryptoServiceConstraintsException:
if the service violates the current constraints.
checkPermissionback to summary
private static void checkPermission(final Permission permission)
chooseLowerBoundback to summary
private static int chooseLowerBound(int pSize)
clearGlobalPropertyback to summary
public static <T> T[] clearGlobalProperty(CryptoServicesRegistrar.Property property)

Clear the global value for the passed in property.

Parameters
<T>
the base type of the property value
property:CryptoServicesRegistrar.Property

the property to be cleared.

Returns:T[]

an array of T if a value was previously set, null otherwise.

clearThreadPropertyback to summary
public static <T> T[] clearThreadProperty(CryptoServicesRegistrar.Property property)

Clear the thread local value for the passed in property.

Parameters
<T>
the base type of the property value
property:CryptoServicesRegistrar.Property

the property to be cleared.

Returns:T[]

an array of T if a value was previously set, null otherwise.

getDefaultConstraintsback to summary
private static CryptoServicesConstraints getDefaultConstraints()
getPropertyback to summary
public static <T> T getProperty(CryptoServicesRegistrar.Property property)

Return the default value for a particular property if one exists. The look up is done on the thread's local configuration first and then on the global configuration in no local configuration exists.

Parameters
<T>
the type to be returned
property:CryptoServicesRegistrar.Property

the property to look up.

Returns:T

null if the property is not set, the default value otherwise,

getSecureRandomback to summary
public static SecureRandom getSecureRandom()

Return the default source of randomness.

Returns:SecureRandom

the default SecureRandom

getSecureRandomback to summary
public static SecureRandom getSecureRandom(SecureRandom secureRandom)

Return either the passed-in SecureRandom, or if it is null, then the default source of randomness.

Parameters
secureRandom:SecureRandom

the SecureRandom to use if it is not null.

Returns:SecureRandom

the SecureRandom parameter if it is not null, or else the default SecureRandom

getServicesConstraintsback to summary
public static CryptoServicesConstraints getServicesConstraints()

Return the current algorithm/services constraints.

Returns:CryptoServicesConstraints

the algorithm/services constraints.

getSizedPropertyback to summary
public static <T> T[] getSizedProperty(CryptoServicesRegistrar.Property property)

Return an array representing the current values for a sized property such as DH_DEFAULT_PARAMS or DSA_DEFAULT_PARAMS.

Parameters
<T>
the base type of the array to be returned.
property:CryptoServicesRegistrar.Property

the name of the property to look up.

Returns:T[]

null if the property is not set, an array of the current values otherwise.

getSizedPropertyback to summary
public static <T> T getSizedProperty(CryptoServicesRegistrar.Property property, int size)

Return the value for a specific size for a sized property such as DH_DEFAULT_PARAMS or DSA_DEFAULT_PARAMS.

Parameters
<T>
the type of the value to be returned.
property:CryptoServicesRegistrar.Property

the name of the property to look up.

size:int

the size (in bits) of the defining value in the property type.

Returns:T

the current value for the size, null if there is no value set,

localClearThreadPropertyback to summary
private static Object[] localClearThreadProperty(CryptoServicesRegistrar.Property property)
localSetGlobalPropertyback to summary
private static <T> void localSetGlobalProperty(CryptoServicesRegistrar.Property property, T... propertyValue)
localSetThreadback to summary
private static <T> void localSetThread(CryptoServicesRegistrar.Property property, T[] propertyValue)
lookupPropertyback to summary
private static Object[] lookupProperty(CryptoServicesRegistrar.Property property)
setGlobalPropertyback to summary
public static <T> void setGlobalProperty(CryptoServicesRegistrar.Property property, T... propertyValue)

Set the value of the the passed in property globally in the JVM. More than one value can be passed in for a sized property. If more than one value is provided the first value in the argument list becomes the default value.

Parameters
<T>
the base type of the property value.
property:CryptoServicesRegistrar.Property

the name of the property to set.

propertyValue:T[]

the values to assign to the property.

setSecureRandomback to summary
public static void setSecureRandom(final SecureRandom secureRandom)

Set a default secure random to be used where none is otherwise provided.

Parameters
secureRandom:SecureRandom

the SecureRandom to use as the default.

setSecureRandomProviderback to summary
public static void setSecureRandomProvider(SecureRandomProvider secureRandomProvider)

Set a default secure random provider to be used where none is otherwise provided.

Parameters
secureRandomProvider:SecureRandomProvider

a provider SecureRandom to use when a default SecureRandom is requested.

setServicesConstraintsback to summary
public static void setServicesConstraints(CryptoServicesConstraints constraints)

Set the current algorithm constraints.

setThreadPropertyback to summary
public static <T> void setThreadProperty(CryptoServicesRegistrar.Property property, T... propertyValue)

Set the value of the the passed in property on the current thread only. More than one value can be passed in for a sized property. If more than one value is provided the first value in the argument list becomes the default value.

Parameters
<T>
the base type of the property value.
property:CryptoServicesRegistrar.Property

the name of the property to set.

propertyValue:T[]

the values to assign to the property.

toDHback to summary
private static DHParameters toDH(DSAParameters dsaParams)
org.bouncycastle.crypto back to summary

public final Class CryptoServicesRegistrar.Property

extends Object
Class Inheritance

Available properties that can be set.

Field Summary

Modifier and TypeField and Description
public static final CryptoServicesRegistrar.Property
DH_DEFAULT_PARAMS

The default parameters for a particular size of Diffie-Hellman key.This is a sized property.

public static final CryptoServicesRegistrar.Property
DSA_DEFAULT_PARAMS

The default parameters for a particular size of DSA key.

public static final CryptoServicesRegistrar.Property
EC_IMPLICITLY_CA

The parameters to be used for processing implicitlyCA X9.62 parameters

private final String
private final Class<T>

Constructor Summary

AccessConstructor and Description
private
Property(String name, Class<T> type)

Method Summary

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

DH_DEFAULT_PARAMSback to summary
public static final CryptoServicesRegistrar.Property DH_DEFAULT_PARAMS

The default parameters for a particular size of Diffie-Hellman key.This is a sized property.

DSA_DEFAULT_PARAMSback to summary
public static final CryptoServicesRegistrar.Property DSA_DEFAULT_PARAMS

The default parameters for a particular size of DSA key. This is a sized property.

EC_IMPLICITLY_CAback to summary
public static final CryptoServicesRegistrar.Property EC_IMPLICITLY_CA

The parameters to be used for processing implicitlyCA X9.62 parameters

nameback to summary
private final String name
typeback to summary
private final Class<T> type

Constructor Detail

Propertyback to summary
private Property(String name, Class<T> type)
org.bouncycastle.crypto back to summary

private Class CryptoServicesRegistrar.ThreadLocalSecureRandomProvider

extends Object
implements SecureRandomProvider
Class Inheritance
  • java.lang.Object
  • org.bouncycastle.crypto.CryptoServicesRegistrar.ThreadLocalSecureRandomProvider
All Implemented Interfaces
org.bouncycastle.crypto.SecureRandomProvider

Field Summary

Modifier and TypeField and Description
pack-priv final ThreadLocal<SecureRandom>

Constructor Summary

AccessConstructor and Description
private

Method Summary

Modifier and TypeMethod and Description
public SecureRandom
get()

Implements org.bouncycastle.crypto.SecureRandomProvider.get.

Return a SecureRandom instance.
Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

defaultRandomsback to summary
pack-priv final ThreadLocal<SecureRandom> defaultRandoms

Constructor Detail

ThreadLocalSecureRandomProviderback to summary
private ThreadLocalSecureRandomProvider()

Method Detail

getback to summary
public SecureRandom get()

Implements org.bouncycastle.crypto.SecureRandomProvider.get.

Doc from org.bouncycastle.crypto.SecureRandomProvider.get.

Return a SecureRandom instance.

Returns:SecureRandom

a SecureRandom