javacard.security.DESKey Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of jcardsim Show documentation
Show all versions of jcardsim Show documentation
jCardSim is open-source library contains implementation of Java Card API
The newest version!
/*
* Copyright 2011 Licel LLC.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package javacard.security;
/**
* DESKey
contains an 8/16/24-byte key for single/2 key triple DES/3 key triple DES
* operations.
* When the key data is set, the key is initialized and ready for use.
* @see KeyBuilder
* @see Signature
* @see javacardx.crypto.Cipher
* @see javacardx.crypto.KeyEncryption
*
*/
public interface DESKey
extends SecretKey {
/**
* Sets the Key
data. The plain text length of input key data is 8 bytes for DES,
* 16 bytes for 2-key triple DES and 24 bytes for 3-key triple DES.
* The data format is big-endian and right-aligned (the least significant bit is the least significant
* bit of last byte). Input key data is copied into the internal representation.
*
Note:
* - If the key object implements the
javacardx.crypto.KeyEncryption
* interface and the Cipher
object specified via setKeyCipher()
* is not null
, keyData
is decrypted using the Cipher
object.
*
* @param keyData byte array containing key initialization data
* @param kOff offset within keyData to start
* @throws CryptoException with the following reason code:
*
* CryptoException.ILLEGAL_VALUE
if input data decryption is required and fails.
*
* @throws NullPointerException - if the keyData
parameter is null
* @throws ArrayIndexOutOfBoundsException if kOff
is negative
* or the keyData
array is too short
*/
public abstract void setKey(byte[] keyData, short kOff)
throws CryptoException, NullPointerException, ArrayIndexOutOfBoundsException;
/**
* Returns the Key
data in plain text. The length of output key data is 8 bytes for DES,
* 16 bytes for 2-key triple DES and 24 bytes for 3-key triple DES.
* The data format is big-endian and right-aligned (the least significant bit is the least significant
* bit of last byte).
* @param keyData byte array to return key data
* @param kOff offset within keyData
to start
* @return the byte length of the key data returned
* @throws CryptoException with the following reason code:
*
* CryptoException.UNINITIALIZED_KEY
if the key data has not been
* successfully initialized since the
* time the initialized state of the key was set to false.
*
* @see Key
*/
public abstract byte getKey(byte[] keyData, short kOff)
throws CryptoException;
}