CipherSpi Class
Definition
Important
Some information relates to prerelease product that may be substantially modified before it’s released. Microsoft makes no warranties, express or implied, with respect to the information provided here.
This class defines the Service Provider Interface (<b>SPI</b>)
for the Cipher
class.
[Android.Runtime.Register("javax/crypto/CipherSpi", DoNotGenerateAcw=true)]
public abstract class CipherSpi : Java.Lang.Object
[<Android.Runtime.Register("javax/crypto/CipherSpi", DoNotGenerateAcw=true)>]
type CipherSpi = class
inherit Object
- Inheritance
- Attributes
Remarks
This class defines the Service Provider Interface (<b>SPI</b>) for the Cipher
class. All the abstract methods in this class must be implemented by each cryptographic service provider who wishes to supply the implementation of a particular cipher algorithm.
In order to create an instance of Cipher
, which encapsulates an instance of this CipherSpi
class, an application calls one of the Cipher#getInstance(java.lang.String) getInstance
factory methods of the Cipher Cipher
engine class and specifies the requested transformation. Optionally, the application may also specify the name of a provider.
A transformation is a string that describes the operation (or set of operations) to be performed on the given input, to produce some output. A transformation always includes the name of a cryptographic algorithm (e.g., DES), and may be followed by a feedback mode and padding scheme.
A transformation is of the form:
<ul> <li>"algorithm/mode/padding" or
<li>"algorithm" </ul>
(in the latter case, provider-specific default values for the mode and padding scheme are used). For example, the following is a valid transformation:
{@code
Cipher c = Cipher.getInstance("DES/CBC/PKCS5Padding");
}
A provider may supply a separate class for each combination of algorithm/mode/padding, or may decide to provide more generic classes representing sub-transformations corresponding to algorithm or algorithm/mode or algorithm//padding (note the double slashes), in which case the requested mode and/or padding are set automatically by the getInstance
methods of Cipher
, which invoke the #engineSetMode(java.lang.String) engineSetMode
and #engineSetPadding(java.lang.String) engineSetPadding
methods of the provider's subclass of CipherSpi
.
A Cipher
property in a provider master class may have one of the following formats:
<ul>
<li>
// provider's subclass of "CipherSpi" implements "algName" with
// pluggable mode and padding
<code>Cipher.</code><i>algName</i>
<li>
// provider's subclass of "CipherSpi" implements "algName" in the
// specified "mode", with pluggable padding
<code>Cipher.</code><i>algName/mode</i>
<li>
// provider's subclass of "CipherSpi" implements "algName" with the
// specified "padding", with pluggable mode
<code>Cipher.</code><i>algName//padding</i>
<li>
// provider's subclass of "CipherSpi" implements "algName" with the
// specified "mode" and "padding"
<code>Cipher.</code><i>algName/mode/padding</i>
</ul>
For example, a provider may supply a subclass of CipherSpi
that implements DES/ECB/PKCS5Padding, one that implements DES/CBC/PKCS5Padding, one that implements DES/CFB/PKCS5Padding, and yet another one that implements DES/OFB/PKCS5Padding. That provider would have the following Cipher
properties in its master class:
<ul>
<li>
<code>Cipher.</code><i>DES/ECB/PKCS5Padding</i>
<li>
<code>Cipher.</code><i>DES/CBC/PKCS5Padding</i>
<li>
<code>Cipher.</code><i>DES/CFB/PKCS5Padding</i>
<li>
<code>Cipher.</code><i>DES/OFB/PKCS5Padding</i>
</ul>
Another provider may implement a class for each of the above modes (i.e., one class for ECB, one for CBC, one for CFB, and one for OFB), one class for PKCS5Padding, and a generic DES class that subclasses from CipherSpi
. That provider would have the following Cipher
properties in its master class:
<ul>
<li>
<code>Cipher.</code><i>DES</i>
</ul>
The getInstance
factory method of the Cipher
engine class follows these rules in order to instantiate a provider's implementation of CipherSpi
for a transformation of the form "algorithm":
<ol> <li> Check if the provider has registered a subclass of CipherSpi
for the specified "algorithm".
If the answer is YES, instantiate this class, for whose mode and padding scheme default values (as supplied by the provider) are used.
If the answer is NO, throw a NoSuchAlgorithmException
exception. </ol>
The getInstance
factory method of the Cipher
engine class follows these rules in order to instantiate a provider's implementation of CipherSpi
for a transformation of the form "algorithm/mode/padding":
<ol> <li> Check if the provider has registered a subclass of CipherSpi
for the specified "algorithm/mode/padding" transformation.
If the answer is YES, instantiate it.
If the answer is NO, go to the next step. <li> Check if the provider has registered a subclass of CipherSpi
for the sub-transformation "algorithm/mode".
If the answer is YES, instantiate it, and call engineSetPadding(<i>padding</i>)
on the new instance.
If the answer is NO, go to the next step. <li> Check if the provider has registered a subclass of CipherSpi
for the sub-transformation "algorithm//padding" (note the double slashes).
If the answer is YES, instantiate it, and call engineSetMode(<i>mode</i>)
on the new instance.
If the answer is NO, go to the next step. <li> Check if the provider has registered a subclass of CipherSpi
for the sub-transformation "algorithm".
If the answer is YES, instantiate it, and call engineSetMode(<i>mode</i>)
and engineSetPadding(<i>padding</i>)
on the new instance.
If the answer is NO, throw a NoSuchAlgorithmException
exception. </ol>
Added in 1.4.
Java documentation for javax.crypto.CipherSpi
.
Portions of this page are modifications based on work created and shared by the Android Open Source Project and used according to terms described in the Creative Commons 2.5 Attribution License.
Constructors
CipherSpi() |
Creates a new |
CipherSpi(IntPtr, JniHandleOwnership) |
A constructor used when creating managed representations of JNI objects; called by the runtime. |
Properties
Class |
Returns the runtime class of this |
Handle |
The handle to the underlying Android instance. (Inherited from Object) |
JniIdentityHashCode | (Inherited from Object) |
JniPeerMembers | |
PeerReference | (Inherited from Object) |
ThresholdClass |
This API supports the Mono for Android infrastructure and is not intended to be used directly from your code. |
ThresholdType |
This API supports the Mono for Android infrastructure and is not intended to be used directly from your code. |
Methods
Clone() |
Creates and returns a copy of this object. (Inherited from Object) |
Dispose() | (Inherited from Object) |
Dispose(Boolean) | (Inherited from Object) |
EngineDoFinal(Byte[], Int32, Int32, Byte[], Int32) |
Encrypts or decrypts data in a single-part operation, or finishes a multiple-part operation. |
EngineDoFinal(Byte[], Int32, Int32) |
Encrypts or decrypts data in a single-part operation, or finishes a multiple-part operation. |
EngineDoFinal(ByteBuffer, ByteBuffer) |
Encrypts or decrypts data in a single-part operation, or finishes a multiple-part operation. |
EngineGetBlockSize() |
Returns the block size (in bytes). |
EngineGetIV() |
Returns the initialization vector (IV) in a new buffer. |
EngineGetKeySize(IKey) |
Returns the key size of the given key object in bits. |
EngineGetOutputSize(Int32) |
Returns the length in bytes that an output buffer would
need to be in order to hold the result of the next |
EngineGetParameters() |
Returns the parameters used with this cipher. |
EngineInit(Int32, IKey, AlgorithmParameters, SecureRandom) |
Initializes this cipher with a key, a set of algorithm parameters, and a source of randomness. |
EngineInit(Int32, IKey, IAlgorithmParameterSpec, SecureRandom) |
Initializes this cipher with a key, a set of algorithm parameters, and a source of randomness. |
EngineInit(Int32, IKey, SecureRandom) |
Initializes this cipher with a key and a source of randomness. |
EngineSetMode(String) |
Sets the mode of this cipher. |
EngineSetPadding(String) |
Sets the padding mechanism of this cipher. |
EngineUnwrap(Byte[], String, Int32) |
Unwrap a previously wrapped key. |
EngineUpdate(Byte[], Int32, Int32, Byte[], Int32) |
Continues a multiple-part encryption or decryption operation (depending on how this cipher was initialized), processing another data part. |
EngineUpdate(Byte[], Int32, Int32) |
Continues a multiple-part encryption or decryption operation (depending on how this cipher was initialized), processing another data part. |
EngineUpdate(ByteBuffer, ByteBuffer) |
Continues a multiple-part encryption or decryption operation (depending on how this cipher was initialized), processing another data part. |
EngineUpdateAAD(Byte[], Int32, Int32) |
Continues a multi-part update of the Additional Authentication Data (AAD), using a subset of the provided buffer. |
EngineUpdateAAD(ByteBuffer) |
Continues a multi-part update of the Additional Authentication Data (AAD). |
EngineWrap(IKey) |
Wrap a key. |
Equals(Object) |
Indicates whether some other object is "equal to" this one. (Inherited from Object) |
GetHashCode() |
Returns a hash code value for the object. (Inherited from Object) |
JavaFinalize() |
Called by the garbage collector on an object when garbage collection determines that there are no more references to the object. (Inherited from Object) |
Notify() |
Wakes up a single thread that is waiting on this object's monitor. (Inherited from Object) |
NotifyAll() |
Wakes up all threads that are waiting on this object's monitor. (Inherited from Object) |
SetHandle(IntPtr, JniHandleOwnership) |
Sets the Handle property. (Inherited from Object) |
ToArray<T>() | (Inherited from Object) |
ToString() |
Returns a string representation of the object. (Inherited from Object) |
UnregisterFromRuntime() | (Inherited from Object) |
Wait() |
Causes the current thread to wait until it is awakened, typically by being <em>notified</em> or <em>interrupted</em>. (Inherited from Object) |
Wait(Int64, Int32) |
Causes the current thread to wait until it is awakened, typically by being <em>notified</em> or <em>interrupted</em>, or until a certain amount of real time has elapsed. (Inherited from Object) |
Wait(Int64) |
Causes the current thread to wait until it is awakened, typically by being <em>notified</em> or <em>interrupted</em>, or until a certain amount of real time has elapsed. (Inherited from Object) |
Explicit Interface Implementations
IJavaPeerable.Disposed() | (Inherited from Object) |
IJavaPeerable.DisposeUnlessReferenced() | (Inherited from Object) |
IJavaPeerable.Finalized() | (Inherited from Object) |
IJavaPeerable.JniManagedPeerState | (Inherited from Object) |
IJavaPeerable.SetJniIdentityHashCode(Int32) | (Inherited from Object) |
IJavaPeerable.SetJniManagedPeerState(JniManagedPeerStates) | (Inherited from Object) |
IJavaPeerable.SetPeerReference(JniObjectReference) | (Inherited from Object) |
Extension Methods
JavaCast<TResult>(IJavaObject) |
Performs an Android runtime-checked type conversion. |
JavaCast<TResult>(IJavaObject) | |
GetJniTypeName(IJavaPeerable) |