Module: Toybox.Cryptography
Overview
Classes Under Namespace
Classes: Cipher, CipherBasedMessageAuthenticationCode, Hash, HashBasedMessageAuthenticationCode, InvalidBlockSizeException, Key, KeyAgreement, KeyPair
Constant Summary
-
HashAlgorithm
-
CipherAlgorithm
-
EncryptionMode
-
KeyPairAlgorithm
-
KeyAgreementProtocol
Name | Value | Since | Description | See Also |
---|---|---|---|---|
HASH_SHA1 | 0 | API Level 3.0.0 |
SHA-1 implementation for Hash objects |
|
HASH_SHA256 | 1 | API Level 3.0.0 |
SHA-256 implementation for Hash objects |
|
HASH_MD5 | 2 | API Level 3.0.0 |
MD5 implementation for Hash objects |
Name | Value | Since | Description | See Also |
---|---|---|---|---|
CIPHER_AES128 | 0 | API Level 3.0.0 |
AES128 implementation for Cipher objects |
|
CIPHER_AES256 | 1 | API Level 3.0.0 |
AES256 implementation for Cipher objects |
Name | Value | Since | Description | See Also |
---|---|---|---|---|
MODE_ECB | 0 | API Level 3.0.0 |
Electronic Code Book (ECB) This is the simplest encryption mode. Each plaintext block is directly encrypted into a ciphertext block, independent of any other block. This mode exposes frequency of symbols in your plaintext. Other modes (e.g. CBC) are recommended. |
|
MODE_CBC | 1 | API Level 3.0.0 |
Cipher-Block Chaining Each ciphertext block depends on the current and all previous plaintext blocks. An Initialization Vector (IV) is required. The IV is a data block to be transmitted to the receiver. The IV can be made public, but it must be authenticated by the receiver and it should be picked randomly. |
Name | Value | Since | Description | See Also |
---|---|---|---|---|
KEY_PAIR_ELLIPTIC_CURVE_SECP224R1 | 0 | API Level 3.0.0 |
224-bit secp224r1 Elliptic Curve Based on the algebraic structure of elliptic curves over finite fields. ECC requires smaller keys compared to non-ECC cryptography to provide equivalent security. |
|
KEY_PAIR_ELLIPTIC_CURVE_SECP256R1 | 1 | API Level 3.0.0 |
256-bit secp256r1 Elliptic Curve Based on the algebraic structure of elliptic curves over finite fields. ECC requires smaller keys compared to non-ECC cryptography to provide equivalent security. |
Name | Value | Since | Description | See Also |
---|---|---|---|---|
KEY_AGREEMENT_ECDH | 0 | API Level 3.0.0 |
Elliptic Curve Diffie-Hellman (ECDH) |
Instance Method Summary collapse
-
createPublicKey(algorithm as Cryptography.HashAlgorithm, bytes as Lang.ByteArray) as Cryptography.Key
Create a public Key object from bytes to be added to a KeyAgreement.
-
randomBytes(size as Lang.Number) as Lang.ByteArray
Generates cryptographically random bytes.
Instance Method Details
createPublicKey(algorithm as Cryptography.HashAlgorithm, bytes as Lang.ByteArray) as Cryptography.Key
Create a public Key object from bytes to be added to a KeyAgreement.
If a public key is received from another party, it can be converted to a Key object using this method.
bytes is expected to be in little-endian byte order.
randomBytes(size as Lang.Number) as Lang.ByteArray
Generates cryptographically random bytes.