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, org.bouncycastle.crypto.asymmetric.DHDomainParameters, .DHValidationParameters, .DSADomainParameters, .DSAValidationParameters, .ECDomainParameters, org.bouncycastle.crypto.fips.FipsSecureRandom, .FipsStatus, .FipsUnapprovedOperationError, org.bouncycastle.jcajce.provider.BouncyCastleFipsProvider, org.bouncycastle.util.Properties, 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.

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 Permission
private static volatile SecureRandom
private static final Map<String, Object[]>
private static final boolean
public static final String
private static final ThreadLocal<Boolean>
private static final ThreadLocal<Map<String, Object[]>>

Constructor Summary

AccessConstructor and Description
private

Method Summary

Modifier and TypeMethod and Description
private static void
checkPermission(final Permission permission)

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.

pack-priv static boolean
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:

a default SecureRandom, or one sourced from the provider if no default is available.
getSecureRandomIfSet
(SecureRandomProvider
the provider of SecureRandom to use if no default is provided.
secureRandomProvider
)

If the default source of randomness is not set, return a SecureRandom generated from the passed in SecureRandomProvider.

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.

public static boolean

Returns:

true if the current thread is in approved mode, false otherwise.
isInApprovedOnlyMode
()

Return true or false depending on whether the current thread is in approved mode.

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

private static Object[]
public static boolean

Returns:

true if the function has set the thread to approved mode, false otherwise.
setApprovedOnlyMode
(boolean
true if should be approved mode, false otherwise.
isApprovedOnly
)

Set the calling thread's approved mode status.

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(SecureRandom
the SecureRandom to use as the default.
secureRandom
)

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

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 DHDomainParameters
Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

AbleToChangeToApprovedModeback to summary
private static final Permission AbleToChangeToApprovedMode
AbleToUseUnapprovedModeback to summary
private static final Permission AbleToUseUnapprovedMode
CanSetDefaultPropertyback to summary
private static final Permission CanSetDefaultProperty
CanSetDefaultRandomback to summary
private static final Permission CanSetDefaultRandom
CanSetThreadPropertyback to summary
private static final Permission CanSetThreadProperty
defaultSecureRandomback to summary
private static volatile SecureRandom defaultSecureRandom
globalPropertiesback to summary
private static final Map<String, Object[]> globalProperties
isDefaultModeApprovedModeback to summary
private static final boolean isDefaultModeApprovedMode
MODULE_HMAC_KEYback to summary
public static final String MODULE_HMAC_KEY
threadFipsModeback to summary
private static final ThreadLocal<Boolean> threadFipsMode
threadPropertiesback to summary
private static final ThreadLocal<Map<String, Object[]>> threadProperties

Constructor Detail

CryptoServicesRegistrarback to summary
private CryptoServicesRegistrar()

Method Detail

checkPermissionback to summary
private static void checkPermission(final Permission permission)
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.

getDefaultModeback to summary
pack-priv static boolean getDefaultMode()
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

Exceptions
IllegalStateException:
if no source of randomness has been provided.
getSecureRandomIfSetback to summary
public static SecureRandom getSecureRandomIfSet(SecureRandomProvider secureRandomProvider)

If the default source of randomness is not set, return a SecureRandom generated from the passed in SecureRandomProvider.

Parameters
secureRandomProvider:SecureRandomProvider

the provider of SecureRandom to use if no default is provided.

Returns:SecureRandom

a default SecureRandom, or one sourced from the provider if no default is available.

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,

isInApprovedOnlyModeback to summary
public static boolean isInApprovedOnlyMode()

Return true or false depending on whether the current thread is in approved mode.

Returns:boolean

true if the current thread is in approved mode, false otherwise.

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)
setApprovedOnlyModeback to summary
public static boolean setApprovedOnlyMode(boolean isApprovedOnly)

Set the calling thread's approved mode status.

Note

a thread cannot move to unapproved mode once it has moved into approved mode.

Parameters
isApprovedOnly:boolean

true if should be approved mode, false otherwise.

Returns:boolean

true if the function has set the thread to approved mode, false otherwise.

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(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.

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 DHDomainParameters toDH(DSADomainParameters 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)