XU XUv0.16.0

#crypto/cipher

import: #crypto/cipher

counts: 18 functions, 3 methods, 2 types, 0 constants, 0 method sets

AES-CBC/CTR/GCM bound to crypto.aes.Cipher.

pad_pkcs7

XuAPI
pub fn pad_pkcs7(src &string, block_size int) string

Purpose

Pad pkcs7. Throws on failure; handle the error or propagate it to the caller.

Parameters

src &string
source (read-only borrow; caller keeps the original; type &string)
block_size int
block_size (int)

Returns

string — result string

unpad_pkcs7_block

XuAPI
pub fn unpad_pkcs7_block(src &string, block_size int) string

Purpose

Unpad pkcs7 block. Throws on failure; handle the error or propagate it to the caller.

Parameters

src &string
source (read-only borrow; caller keeps the original; type &string)
block_size int
block_size (int)

Returns

string — result string

unpad_pkcs7

XuAPI
pub fn unpad_pkcs7(src &string) string

Purpose

Unpad pkcs7. Throws on failure; handle the error or propagate it to the caller.

Parameters

src &string
source (read-only borrow; caller keeps the original; type &string)

Returns

string — result string

encrypt_cbc

XuAPI
pub fn encrypt_cbc(c &aes.Cipher, iv &string, src &string) string

Purpose

Encrypt cbc. Throws on failure; handle the error or propagate it to the caller.

Parameters

c &aes.Cipher
byte or character code (read-only borrow; caller keeps the original; type &aes.Cipher)
iv &string
int payload or initialization vector (read-only borrow; caller keeps the original; type &string)
src &string
source (read-only borrow; caller keeps the original; type &string)

Returns

string — result string

decrypt_cbc

XuAPI
pub fn decrypt_cbc(c &aes.Cipher, iv &string, src &string) string

Purpose

Decrypt cbc. Throws on failure; handle the error or propagate it to the caller.

Parameters

c &aes.Cipher
byte or character code (read-only borrow; caller keeps the original; type &aes.Cipher)
iv &string
int payload or initialization vector (read-only borrow; caller keeps the original; type &string)
src &string
source (read-only borrow; caller keeps the original; type &string)

Returns

string — result string

encrypt_cbc_pkcs7

XuAPI
pub fn encrypt_cbc_pkcs7(c &aes.Cipher, iv &string, src &string) string

Purpose

Encrypt cbc pkcs7. Throws on failure; handle the error or propagate it to the caller.

Parameters

c &aes.Cipher
byte or character code (read-only borrow; caller keeps the original; type &aes.Cipher)
iv &string
int payload or initialization vector (read-only borrow; caller keeps the original; type &string)
src &string
source (read-only borrow; caller keeps the original; type &string)

Returns

string — result string

decrypt_cbc_pkcs7

XuAPI
pub fn decrypt_cbc_pkcs7(c &aes.Cipher, iv &string, src &string) string

Purpose

Decrypt cbc pkcs7. Throws on failure; handle the error or propagate it to the caller.

Parameters

c &aes.Cipher
byte or character code (read-only borrow; caller keeps the original; type &aes.Cipher)
iv &string
int payload or initialization vector (read-only borrow; caller keeps the original; type &string)
src &string
source (read-only borrow; caller keeps the original; type &string)

Returns

string — result string

encrypt_ctr

XuAPI
pub fn encrypt_ctr(c &aes.Cipher, iv &string, src &string) string

Purpose

Encrypt ctr.

Parameters

c &aes.Cipher
byte or character code (read-only borrow; caller keeps the original; type &aes.Cipher)
iv &string
int payload or initialization vector (read-only borrow; caller keeps the original; type &string)
src &string
source (read-only borrow; caller keeps the original; type &string)

Returns

string — result string

decrypt_ctr

XuAPI
pub fn decrypt_ctr(c &aes.Cipher, iv &string, src &string) string

Purpose

Decrypt ctr.

Parameters

c &aes.Cipher
byte or character code (read-only borrow; caller keeps the original; type &aes.Cipher)
iv &string
int payload or initialization vector (read-only borrow; caller keeps the original; type &string)
src &string
source (read-only borrow; caller keeps the original; type &string)

Returns

string — result string

struct Ctr

XuAPI
pub struct Ctr {

}

Purpose

Ctr is a resumable CTR keystream ( cipher.NewCTR): successive xor_key_stream calls continue mid-block where the previous one stopped.

Public fields

This type has no public fields.

new_ctr

XuAPI
pub fn new_ctr(c aes.Cipher, iv &string) Ctr

Purpose

Construct ctr. Throws on failure; handle the error or propagate it to the caller.

Parameters

c aes.Cipher
byte or character code (aes.Cipher)
iv &string
int payload or initialization vector (read-only borrow; caller keeps the original; type &string)

Returns

Ctr — a value of this type

($&Ctr) xor_key_stream

XuAPI
pub fn (s $&Ctr) xor_key_stream(src &string) string

Purpose

Operation on $&Ctr: xor key stream. Throws on failure; handle the error or propagate it to the caller.

Parameters

s $&Ctr
The Ctr instance used by this call (exclusive borrow).
src &string
source (read-only borrow; caller keeps the original; type &string)

Returns

string — result string

encrypt_ofb

XuAPI
pub fn encrypt_ofb(c &aes.Cipher, iv &string, src &string) string

Purpose

Encrypt ofb. Throws on failure; handle the error or propagate it to the caller.

Parameters

c &aes.Cipher
byte or character code (read-only borrow; caller keeps the original; type &aes.Cipher)
iv &string
int payload or initialization vector (read-only borrow; caller keeps the original; type &string)
src &string
source (read-only borrow; caller keeps the original; type &string)

Returns

string — result string

decrypt_ofb

XuAPI
pub fn decrypt_ofb(c &aes.Cipher, iv &string, src &string) string

Purpose

Decrypt ofb. Throws on failure; handle the error or propagate it to the caller.

Parameters

c &aes.Cipher
byte or character code (read-only borrow; caller keeps the original; type &aes.Cipher)
iv &string
int payload or initialization vector (read-only borrow; caller keeps the original; type &string)
src &string
source (read-only borrow; caller keeps the original; type &string)

Returns

string — result string

encrypt_cfb

XuAPI
pub fn encrypt_cfb(c &aes.Cipher, iv &string, src &string) string

Purpose

Encrypt cfb. Throws on failure; handle the error or propagate it to the caller.

Parameters

c &aes.Cipher
byte or character code (read-only borrow; caller keeps the original; type &aes.Cipher)
iv &string
int payload or initialization vector (read-only borrow; caller keeps the original; type &string)
src &string
source (read-only borrow; caller keeps the original; type &string)

Returns

string — result string

decrypt_cfb

XuAPI
pub fn decrypt_cfb(c &aes.Cipher, iv &string, src &string) string

Purpose

Decrypt cfb. Throws on failure; handle the error or propagate it to the caller.

Parameters

c &aes.Cipher
byte or character code (read-only borrow; caller keeps the original; type &aes.Cipher)
iv &string
int payload or initialization vector (read-only borrow; caller keeps the original; type &string)
src &string
source (read-only borrow; caller keeps the original; type &string)

Returns

string — result string

struct GcmKey

XuAPI
pub struct GcmKey {

}

Purpose

GcmKey context or state structure.

Public fields

This type has no public fields.

empty_gcm

XuAPI
pub fn empty_gcm() GcmKey

Purpose

Empty gcm.

Parameters

No arguments are required.

Returns

GcmKey — a value of this type

new_gcm

XuAPI
pub fn new_gcm(c aes.Cipher) GcmKey

Purpose

Construct gcm. Throws on failure; handle the error or propagate it to the caller.

Parameters

c aes.Cipher
byte or character code (aes.Cipher)

Returns

GcmKey — a value of this type

(&GcmKey) seal

XuAPI
pub fn (g &GcmKey) seal(nonce &string, plaintext &string, aad &string) string

Purpose

Execute seal on &GcmKey. Throws on failure; handle the error or propagate it to the caller.

Parameters

g &GcmKey
The GcmKey instance used by this call (borrow).
nonce &string
nonce (read-only borrow; caller keeps the original; type &string)
plaintext &string
plaintext (read-only borrow; caller keeps the original; type &string)
aad &string
aad (read-only borrow; caller keeps the original; type &string)

Returns

string — result string

(&GcmKey) open

XuAPI
pub fn (g &GcmKey) open(nonce &string, sealed &string, aad &string) string

Purpose

Operation on &GcmKey: open resource or establish connection. Throws on failure; handle the error or propagate it to the caller.

Parameters

g &GcmKey
The GcmKey instance used by this call (borrow).
nonce &string
nonce (read-only borrow; caller keeps the original; type &string)
sealed &string
sealed (read-only borrow; caller keeps the original; type &string)
aad &string
aad (read-only borrow; caller keeps the original; type &string)

Returns

string — result string

seal_gcm

XuAPI
pub fn seal_gcm(c &aes.Cipher, nonce &string, plaintext &string, aad &string) string

Purpose

Seal gcm. Throws on failure; handle the error or propagate it to the caller.

Parameters

c &aes.Cipher
byte or character code (read-only borrow; caller keeps the original; type &aes.Cipher)
nonce &string
nonce (read-only borrow; caller keeps the original; type &string)
plaintext &string
plaintext (read-only borrow; caller keeps the original; type &string)
aad &string
aad (read-only borrow; caller keeps the original; type &string)

Returns

string — result string

open_gcm

XuAPI
pub fn open_gcm(c &aes.Cipher, nonce &string, sealed &string, aad &string) string

Purpose

Open gcm. Throws on failure; handle the error or propagate it to the caller.

Parameters

c &aes.Cipher
byte or character code (read-only borrow; caller keeps the original; type &aes.Cipher)
nonce &string
nonce (read-only borrow; caller keeps the original; type &string)
sealed &string
sealed (read-only borrow; caller keeps the original; type &string)
aad &string
aad (read-only borrow; caller keeps the original; type &string)

Returns

string — result string