This document specifies the Javascript interface to [[!KCipher2]], which is a fast and lightweight stream cipher algorithm developed by KDDI R&D Laboratories Inc.
This document is in a draft stage and is waiting for implementations of KCipher-2 from UserAgent vendors.
The "KCipher2"
algorithm identifier is used to perform encryption and decryption using KCipher-2, as described in [[KCipher2]].
The recognized algorithm name for this algorithm is "KCipher2"
.
Operation | Parameters | Result |
---|---|---|
encrypt | K2KeyCipherParameters | ArrayBuffer |
decrypt | K2KeyCipherParameters | ArrayBuffer |
generateKey | K2KeyGenParameters | CryptoKey |
importKey | None | CryptoKey |
exportKey | None | object |
get key length | K2DerivedKeyParameters | Integer |
dictionary K2KeyCipherParameters : Algorithm { // The initialization vector. MUST be 16 bytes. required BufferSource iv; };
dictionary K2KeyGenParameters : Algorithm { // The length, in bits, of the key. [EnforceRange] required unsigned short length; };
dictionary K2DerivedKeyParameters : Algorithm { // The length, in bits, of the key. [EnforceRange] required unsigned short length; };
OperationError
.
OperationError
.
"encrypt"
, "decrypt"
, "wrapKey"
or "unwrapKey"
, then throw a SyntaxError
.OperationError
."KCipher2"
.
If usages contains an entry which is not one of "encrypt"
, "decrypt"
, "wrapKey"
or "unwrapKey"
, then throw a SyntaxError
.
"raw"
:Let data be the octet string contained in keyData.
If the length in bits of data is not 128, 192 or 256, then throw an OperationError
.
"jwk"
:Let jwk be the JsonWebKey dictionary represented by keyData.
If the "kty"
field of jwk is not "oct"
, then throw a DataError
.
If jwk does not meet the requirements of Section 6.4 of JSON Web Algorithms, then throw n DataError
.
Let data be the octet string obtained by decoding the "k"
field of jwk.
"alg"
field of jwk is present, and is not "KC128"
, then throw a DataError
.
"alg"
field of jwk is present, and is not "KC192"
, then throw a DataError
.
"alg"
field of jwk is present, and is not "KC256"
, then throw a DataError
.
DataError
If the "use"
field of jwk is present, and is not "enc"
, then throw a DataError
.
If the "key_ops"
field of jwk is present, and
is invalid according to the requirements of
JSON Web Key or
does not contain all of the specified usages values, then throw a DataError
.
If the "ext"
field of jwk is present and has the value false and extractable is true, then throw a DataError
.
NotSupportedError
.
Let key be a new CryptoKey
object representing a KCipher-2 key with value data.
Let algorithm be a new K2KeyAlgorithm.
Set the name attribute of algorithm to "KCipher2"
.
Set the length attribute of algorithm to the length, in bits, of data.
Set the [algorithm] internal slot of key to algorithm.
Return key.
If the underlying cryptographic key material represented by the [handle] internal slot of key cannot be accessed, then throw an OperationError
.
"raw"
:Let data be the raw octets of the key represented by [handle] internal slot of key.
Let result be a new ArrayBuffer
containing
data.
"jwk"
:Let jwk be a new JsonWebKey dictionary.
Set the kty
attribute of jwk to the
string "oct"
.
Set the k
attribute of jwk to be a string
containing the raw octets of the key represented by [handle] internal slot of
key, encoded according to Section 6.4 of JSON Web Algorithms.
Set the key_ops
attribute of jwk to equal the
[usages] internal slot of
key.
Set the ext
attribute of jwk to equal the [extractable] internal slot
of key.
Let result be the result of converting jwk to an ECMAScript Object, as defined by [WebIDL].
Return result.