namespace internal

// typedefs

typedef ap_uint <512> blockTypeChacha

// structs

struct SHA256Block
struct blake2BlockType
struct blockType

template <>
struct sha256_digest_config <true>

template <>
struct sha256_digest_config <false>

template <bool do_sha224>
struct sha256_digest_config

struct sm3BlkPack

template <int IW>
struct treeAdd <IW, 0>

template <
    int IW,
    int NW
    >
struct treeAdd

// classes

template <int KeyW>
class aesCbcPack

template <int W>
class packBase

// global variables

const ap_uint <21> BASE[]
const ap_uint <32> table[16][256]
const ap_uint <8> PermMap[64]
const ap_uint <8> IPermMap[64]
const ap_uint <8> ExtMap[48]
const ap_uint <4> SP[8][64]
const ap_int <8> FPermMap[32]
const ap_uint <8> PCMapC[28]
const ap_uint <8> PCMapD[28]
const ap_uint <8> PC2Map[48]
const ap_uint <8> subkeyIndex[16][48]

generateBlock

#include "xf_security/blake2b.hpp"
void generateBlock (
    hls::stream <ap_uint <64>>& msg_strm,
    hls::stream <ap_uint <128>>& msg_len_strm,
    hls::stream <ap_uint <512>>& key_strm,
    hls::stream <ap_uint <8>>& key_len_strm,
    hls::stream <bool>& end_len_strm,
    hls::stream <blake2BlockType>& blk_strm,
    hls::stream <ap_uint <128>>& nblk_strm,
    hls::stream <bool>& end_nblk_strm,
    hls::stream <ap_uint <128>>& msg_len_out_strm,
    hls::stream <ap_uint <8>>& key_len_out_strm
    )

Generate 1024-bit processing blocks by padding (pipeline).

The algorithm reference is : “The BLAKE2 Cryptographic Hash and Message Authentication Code (MAC)”. The optimization goal of this function is to yield a 1024-bit block per cycle.

Parameters:

w Bit width of the message words in block, default value is 64.
msg_strm The message being hashed.
msg_len_strm Message length in byte (0 <= msg_len <= 2^128).
key_strm The optional key.
key_len_strm Key length in byte (0 <= key_len <= 64).
end_len_strm The flag to signal end of input message stream.
blk_strm The 1024-bit hash block.
nblk_strm The number of hash block for this message.
end_nblk_strm End flag for number of hash block.
msg_len_out_strm Message length pass on to the digest process.
key_len_out_strm Key length pass on to the digest process.

ROTR

#include "xf_security/blake2b.hpp"
template <
    unsigned int w = 64,
    unsigned int n = 0
    >
ap_uint <w> ROTR (ap_uint <w> x)

The implementation of rotate right (circular right shift) operation.

The algorithm reference is : “The BLAKE2 Cryptographic Hash and Message Authentication Code (MAC)”.

Parameters:

w The bit width of input x, default value is 64.
n Number of bits for input x to be shifted.
x Word to be rotated.

G

#include "xf_security/blake2b.hpp"
void G (
    ap_uint <64> v [16],
    ap_uint <4> a,
    ap_uint <4> b,
    ap_uint <4> c,
    ap_uint <4> d,
    ap_uint <64> x,
    ap_uint <64> y
    )

Mixing function G as defined in standard.

The algorithm reference is : “The BLAKE2 Cryptographic Hash and Message Authentication Code (MAC)”.

Parameters:

Bit width of the words, default value is 64.
v Working vector.
a The first index.
b The second index.
c The third index.
d the fourth index.
x The first input working word.
y The second input working word.

Compress

#include "xf_security/blake2b.hpp"
void Compress (
    ap_uint <64> h [8],
    ap_uint <64> m [16],
    ap_uint <128> t,
    bool last
    )

Compression function F as defined in standard.

The optimization goal of this function is for better performance. The algorithm reference is : “The BLAKE2 Cryptographic Hash and Message Authentication Code (MAC)”.

Parameters:

w Bit width of the words, default value is 64.
round Number of rounds, 12 for BLAKE2b and 10 for BLAKE2s.
h State vector.
m Message block vector.
t Offset counter.
last Final block indicator.

blake2bDigest

#include "xf_security/blake2b.hpp"
void blake2bDigest (
    hls::stream <blake2BlockType>& blk_strm,
    hls::stream <ap_uint <128>>& nblk_strm,
    hls::stream <bool>& end_nblk_strm,
    hls::stream <ap_uint <8>>& key_len_strm,
    hls::stream <ap_uint <128>>& msg_len_strm,
    hls::stream <ap_uint <8>>& out_len_strm,
    hls::stream <ap_uint <512>>& digest_strm,
    hls::stream <bool>& end_digest_strm
    )

The implementation of the digest prcoess of BLAKE2.

The algorithm reference is : “The BLAKE2 Cryptographic Hash and Message Authentication Code (MAC)”. The optimization goal of this function is for better performance.

Parameters:

w Bit width of the words, default value is 64.
blk_strm The 512-bit hash block.
nblk_strm The number of hash block for this message.
end_nblk_strm End flag for number of hash block.
key_len_strm Key length in byte (0 <= key_len <= 64).
msg_len_strm Message length in byte (0 <= msg_len <= 2^128).
out_len_strm Result hash value length in byte (0 < out_len < 64).
digest_strm The full digest stream (result is stored in the lower out_len bytes).
end_digest_strm Flag to signal the end of the result.

aesCbcEncrypt

#include "xf_security/cbc.hpp"
template <unsigned int _keyWidth = 256>
void aesCbcEncrypt (
    hls::stream <ap_uint <128>>& plaintext,
    hls::stream <bool>& plaintext_e,
    hls::stream <ap_uint <_keyWidth>>& cipherkey,
    hls::stream <ap_uint <128>>& initialization_vector,
    hls::stream <ap_uint <128>>& ciphertext,
    hls::stream <bool>& ciphertext_e
    )

aesCbcEncrypt is CBC encryption mode with AES single block cipher.

The algorithm reference is : “Recommendation for Block Cipher Modes of Operation - Methods and Techniques” The implementation is modified for better performance.

Parameters:

_keyWidth The bit-width of the cipher key, which is 128, 192, or 256.
plaintext Input block stream text to be encrypted, each block is 128 bits.
plaintext_e End flag of block stream plaintext, 1 bit.
cipherkey Input cipher key used in encryption, x bits for AES-x.
initialization_vector Initialization vector for the fisrt iteration of AES encrypition, 128 bits.
ciphertext Output encrypted block stream text, each block is 128 bits.
ciphertext_e End flag of block stream ciphertext, 1 bit.

aesCbcDecrypt

#include "xf_security/cbc.hpp"
template <unsigned int _keyWidth = 256>
void aesCbcDecrypt (
    hls::stream <ap_uint <128>>& ciphertext,
    hls::stream <bool>& ciphertext_e,
    hls::stream <ap_uint <_keyWidth>>& cipherkey,
    hls::stream <ap_uint <128>>& IV_strm,
    hls::stream <ap_uint <128>>& plaintext,
    hls::stream <bool>& plaintext_e
    )

aesCbcDecrypt is CBC decryption mode with AES single block cipher.

The algorithm reference is : “Recommendation for Block Cipher Modes of Operation - Methods and Techniques” The implementation is modified for better performance.

Parameters:

_keyWidth The bit-width of the cipher key, which is 128, 192, or 256.
ciphertext Input block stream text to be decrypted, each block is 128 bits.
ciphertext_e End flag of block stream ciphertext, 1 bit.
cipherkey Input cipher key used in decryption, x bits for AES-x.
initialization_vector Initialization vector for the fisrt iteration of AES decrypition, 128 bits.
plaintext Output decrypted block stream text, each block is 128 bits.
plaintext_e End flag of block stream plaintext, 1 bit.

formatting

#include "xf_security/ccm.hpp"
template <
    unsigned int _t = 16,
    unsigned int _q = 8
    >
void formatting (
    hls::stream <ap_uint <128>>& ADStrm,
    hls::stream <ap_uint <8* (15-_q)>>& nonceStrm,
    hls::stream <ap_uint <64>>& lenADStrm,
    hls::stream <ap_uint <64>>& lenPldStrm,
    hls::stream <bool>& endLenStrm,
    hls::stream <ap_uint <128>>& blockStrm,
    hls::stream <ap_uint <64>>& outLenADStrm,
    hls::stream <ap_uint <8* (15-_q)>>& outNonceStrm
    )

Impletmentation of formatting function as specified in standard.

The algorithm reference is: “Recommendation for Block Cipher Modes of Operation: The CCM Mode for Authentication and Confidentiality” The implementation is modified for better performance.

Parameters:

_t Length of the MAC in byte, t is an element of {4, 6, 8, 10, 12, 14, 16}.
_q Length in byte of the binary representation of the length of the payload in byte, q is an element of {2, 3, 4, 5, 6, 7, 8}.
ADStrm Associated data stream.
nonceStrm The nonce stream.
lenADStrm Length of associated data in byte.
lenPldStrm Length of payload in byte.
endLenStrm Flag to signal the end of the length streams.
blockStrm Block stream of the formatted input as specified in reference.
outLenADStrm Pass on the length of associated data to CBC-MAC.
outNonceStrm Pass on the nonce to CTR.

aesCtrEncrypt

#include "xf_security/ccm.hpp"
template <
    unsigned int _q = 8,
    unsigned int _keyWidth = 256
    >
void aesCtrEncrypt (
    hls::stream <ap_uint <128>>& payloadStrm,
    hls::stream <ap_uint <_keyWidth>>& cipherkeyStrm,
    hls::stream <ap_uint <8* (15-_q)>>& nonceStrm,
    hls::stream <ap_uint <64>>& lenPldStrm,
    hls::stream <bool>& endLenPldStrm,
    hls::stream <ap_uint <128>>& outPayloadStrm,
    hls::stream <ap_uint <_keyWidth>>& outCipherkeyStrm,
    hls::stream <ap_uint <128>>& S0Strm,
    hls::stream <ap_uint <128>>& cipherStrm,
    hls::stream <ap_uint <64>>& lenCphStrm
    )

Implementation of CTR encryption part in CCM.

The algorithm reference is: “Recommendation for Block Cipher Modes of Operation: The CCM Mode for Authentication and Confidentiality” The implementation is modified for better performance.

Parameters:

_q Length in byte of the binary representation of the length of the payload in byte, q is an element of {2, 3, 4, 5, 6, 7, 8}.
_keyWidth Bit-width of the cipher key, typically 128, 192, or 256 for AES.
payloadStrm Input block stream text to be encrypted.
cipherkeyStrm Input cipher key used in encryption.
nonceStrm The nonce stream.
lenPldStrm Length of payload in byte.
endLenPldStrm Flag to signal the end of the payload length stream.
outPayloadStrm Pass on the payload stream to CBC-MAC.
outCipherkeyStrm Pass on the cipherkey to CBC-MAC.
S0Strm First cipher used to generate the MAC.
cipherStrm Output encrypted block stream text.
lenCphStrm Length of cipher in byte.

aesCtrDecrypt

#include "xf_security/ccm.hpp"
template <
    unsigned int _q = 8,
    unsigned int _keyWidth = 256
    >
void aesCtrDecrypt (
    hls::stream <ap_uint <128>>& payloadStrm,
    hls::stream <ap_uint <_keyWidth>>& cipherkeyStrm,
    hls::stream <ap_uint <8* (15-_q)>>& nonceStrm,
    hls::stream <ap_uint <64>>& lenPldStrm,
    hls::stream <bool>& endLenPldStrm,
    hls::stream <ap_uint <128>>& outPayloadStrm,
    hls::stream <ap_uint <_keyWidth>>& outCipherkeyStrm,
    hls::stream <ap_uint <128>>& S0Strm,
    hls::stream <ap_uint <128>>& cipherStrm,
    hls::stream <ap_uint <64>>& lenCphStrm
    )

Implementation of CTR decryption part in CCM.

The algorithm reference is: “Recommendation for Block Cipher Modes of Operation: The CCM Mode for Authentication and Confidentiality” The implementation is modified for better performance.

Parameters:

_q Length in byte of the binary representation of the length of the payload in byte, q is an element of {2, 3, 4, 5, 6, 7, 8}.
_keyWidth Bit-width of the cipher key, typically 128, 192, or 256 for AES.
payloadStrm Input block stream text to be decrypted.
cipherkeyStrm Input cipher key used in decryption.
nonceStrm The nonce stream.
lenPldStrm Length of payload in byte.
endLenPldStrm Flag to signal the end of the payload length stream.
outPayloadStrm Pass on the payload stream to CBC-MAC.
outCipherkeyStrm Pass on the cipherkey to CBC-MAC.
S0Strm First cipher used to generate the MAC.
cipherStrm Output decrypted block stream text.
lenCphStrm Length of cipher in byte.

CBC_MAC

#include "xf_security/ccm.hpp"
template <
    unsigned int _t = 16,
    unsigned int _keyWidth = 256
    >
void CBC_MAC (
    hls::stream <ap_uint <128>>& payloadStrm,
    hls::stream <ap_uint <64>>& lenADStrm,
    hls::stream <ap_uint <64>>& lenPldStrm,
    hls::stream <ap_uint <128>>& blockStrm,
    hls::stream <ap_uint <_keyWidth>>& cipherkeyStrm,
    hls::stream <ap_uint <128>>& S0Strm,
    hls::stream <bool>& endLenStrm,
    hls::stream <ap_uint <8*_t>>& tagStrm,
    hls::stream <bool>& endTagStrm
    )

Impletmentation of CBC-MAC in CCM.

The algorithm reference is: “Recommendation for Block Cipher Modes of Operation: The CCM Mode for Authentication and Confidentiality” The implementation is modified for better performance.

Parameters:

_t Length of the MAC in byte, t is an element of {4, 6, 8, 10, 12, 14, 16}.
_keyWidth Bit-width of the cipher key, typically 128, 192, or 256 for AES.
payloadStrm Input block stream text.
lenADStrm Length of associated data in byte.
lenPldStrm Length of payload in byte.
blockStrm Block stream of the formatted input as specified in reference.
cipherkeyStrm Input cipher key, typically 128, 192, or 256 for AES.
S0Strm First cipher used to generate the MAC.
endLenStrm Flag to signal the end of the length streams.
tagStrm The MAC.
endTagStrm Flag to signal the end of the MAC stream.

aesCcmEncrypt

#include "xf_security/ccm.hpp"
template <
    unsigned int _t = 16,
    unsigned int _q = 8,
    unsigned int _keyWidth = 256
    >
void aesCcmEncrypt (
    hls::stream <ap_uint <128>>& payloadStrm,
    hls::stream <ap_uint <_keyWidth>>& cipherkeyStrm,
    hls::stream <ap_uint <8* (15-_q)>>& nonceStrm,
    hls::stream <ap_uint <128>>& ADStrm,
    hls::stream <ap_uint <64>>& lenADStrm,
    hls::stream <ap_uint <64>>& lenPldStrm,
    hls::stream <bool>& endLenStrm,
    hls::stream <ap_uint <128>>& cipherStrm,
    hls::stream <ap_uint <64>>& lenCphStrm,
    hls::stream <ap_uint <8*_t>>& tagStrm,
    hls::stream <bool>& endTagStrm
    )

aesCcmEncrypt is CCM encryption mode with AES single block cipher.

The algorithm reference is: “Recommendation for Block Cipher Modes of Operation: The CCM Mode for Authentication and Confidentiality” The implementation is modified for better performance.

Parameters:

_t Length of the MAC in byte, t is an element of {4, 6, 8, 10, 12, 14, 16}.
_q Length in byte of the binary representation of the length of the payload in byte, q is an element of {2, 3, 4, 5, 6, 7, 8}.
_keyWidth The bit-width of the cipher key, which is 128, 192, or 256.
payloadStrm Input block stream text to be encrypted.
cipherkeyStrm Input cipher key used in encryption.
nonceStrm The nonce stream.
ADStrm Associated data stream.
lenADStrm Length of associated data in byte.
lenPldStrm Length of payload in byte.
endLenStrm Flag to signal the end of the length streams.
cipherStrm Output encrypted block stream text.
lenCphStrm Length of cipher in byte.
tagStrm The MAC stream.
endTagStrm Flag to signal the end of the MAC stream.

aesCcmDecrypt

#include "xf_security/ccm.hpp"
template <
    unsigned int _t = 16,
    unsigned int _q = 8,
    unsigned int _keyWidth = 256
    >
void aesCcmDecrypt (
    hls::stream <ap_uint <128>>& payloadStrm,
    hls::stream <ap_uint <_keyWidth>>& cipherkeyStrm,
    hls::stream <ap_uint <8* (15-_q)>>& nonceStrm,
    hls::stream <ap_uint <128>>& ADStrm,
    hls::stream <ap_uint <64>>& lenADStrm,
    hls::stream <ap_uint <64>>& lenPldStrm,
    hls::stream <bool>& endLenStrm,
    hls::stream <ap_uint <128>>& cipherStrm,
    hls::stream <ap_uint <64>>& lenCphStrm,
    hls::stream <ap_uint <8*_t>>& tagStrm,
    hls::stream <bool>& endTagStrm
    )

aesCcmDecrypt is CCM decryption mode with AES single block cipher.

The algorithm reference is: “Recommendation for Block Cipher Modes of Operation: The CCM Mode for Authentication and Confidentiality” The implementation is modified for better performance.

Parameters:

_t Length of the MAC in byte, t is an element of {4, 6, 8, 10, 12, 14, 16}.
_q Length in byte of the binary representation of the length of the payload in byte, q is an element of {2, 3, 4, 5, 6, 7, 8}.
_keyWidth The bit-width of the cipher key, which is 128, 192, or 256.
payloadStrm Input block stream text to be decrypted.
cipherkeyStrm Input cipher key used in decryption.
nonceStrm The nonce stream.
ADStrm Associated data stream.
lenADStrm Length of associated data in byte.
lenPldStrm Length of payload in byte.
endLenStrm Flag to signal the end of the length streams.
cipherStrm Output decrypted block stream text.
lenCphStrm Length of cipher in byte.
tagStrm The MAC stream.
endTagStrm Flag to signal the end of the MAC stream.

aesCfb1Encrypt

#include "xf_security/cfb.hpp"
template <unsigned int _keyWidth = 256>
void aesCfb1Encrypt (
    hls::stream <ap_uint <128>>& plaintext,
    hls::stream <bool>& plaintext_e,
    hls::stream <ap_uint <_keyWidth>>& cipherkey,
    hls::stream <ap_uint <128>>& initialization_vector,
    hls::stream <ap_uint <128>>& ciphertext,
    hls::stream <bool>& ciphertext_e
    )

aesCfb1Encrypt is CFB1 encryption mode with AES single block cipher.

The algorithm reference is : “Recommendation for Block Cipher Modes of Operation - Methods and Techniques” The implementation is modified for better performance.

Parameters:

_keyWidth The bit-width of the cipher key, which is 128, 192, or 256.
plaintext Input block stream text to be encrypted, each block is 128 bits.
plaintext_e End flag of block stream plaintext, 1 bit.
cipherkey Input cipher key used in encryption, x bits for AES-x.
initialization_vector Initialization vector for the fisrt iteration of AES encrypition, 128 bits.
ciphertext Output encrypted block stream text, each block is 128 bits.
ciphertext_e End flag of stream ciphertext, 1 bit.

aesCfb1Decrypt

#include "xf_security/cfb.hpp"
template <unsigned int _keyWidth = 256>
void aesCfb1Decrypt (
    hls::stream <ap_uint <128>>& ciphertext,
    hls::stream <bool>& ciphertext_e,
    hls::stream <ap_uint <_keyWidth>>& cipherkey,
    hls::stream <ap_uint <128>>& IV_strm,
    hls::stream <ap_uint <128>>& plaintext,
    hls::stream <bool>& plaintext_e
    )

aesCfb1Decrypt is CFB1 decryption mode with AES single block cipher.

The algorithm reference is : “Recommendation for Block Cipher Modes of Operation - Methods and Techniques” The implementation is modified for better performance.

Parameters:

_keyWidth The bit-width of the cipher key, which is 128, 192, or 256.
ciphertext Input block stream text to be decrypted, each block is 128 bits.
ciphertext_e End flag of block stream ciphertext, 1 bit.
cipherkey Input cipher key used in decryption, x bits for AES-x.
IV_strm Initialization vector for the fisrt iteration of AES decrypition, 128 bits.
plaintext Output decrypted block stream text, each block is 128 bits.
plaintext_e End flag of stream plaintext, 1 bit.

aesCfb8Encrypt

#include "xf_security/cfb.hpp"
template <unsigned int _keyWidth = 256>
void aesCfb8Encrypt (
    hls::stream <ap_uint <128>>& plaintext,
    hls::stream <bool>& plaintext_e,
    hls::stream <ap_uint <_keyWidth>>& cipherkey,
    hls::stream <ap_uint <128>>& initialization_vector,
    hls::stream <ap_uint <128>>& ciphertext,
    hls::stream <bool>& ciphertext_e
    )

aesCfb8Encrypt is CFB8 encryption mode with AES single block cipher.

The algorithm reference is : “Recommendation for Block Cipher Modes of Operation - Methods and Techniques” The implementation is modified for better performance.

Parameters:

_keyWidth The bit-width of the cipher key, which is 128, 192, or 256.
plaintext Input block stream text to be encrypted, each block is 128 bits.
plaintext_e End flag of block stream plaintext, 1 bit.
cipherkey Input cipher key used in encryption, x bits for AES-x.
initialization_vector Initialization vector for the fisrt iteration of AES encrypition, 128 bits.
ciphertext Output encrypted block stream text, each block is 128 bits.
ciphertext_e End flag of stream ciphertext, 1 bit.

aesCfb8Decrypt

#include "xf_security/cfb.hpp"
template <unsigned int _keyWidth>
void aesCfb8Decrypt (
    hls::stream <ap_uint <128>>& ciphertext,
    hls::stream <bool>& ciphertext_e,
    hls::stream <ap_uint <_keyWidth>>& cipherkey,
    hls::stream <ap_uint <128>>& IV_strm,
    hls::stream <ap_uint <128>>& plaintext,
    hls::stream <bool>& plaintext_e
    )

aesCfb8Decrypt is CFB8 decryption mode with AES single block cipher.

The algorithm reference is : “Recommendation for Block Cipher Modes of Operation - Methods and Techniques” The implementation is modified for better performance.

Parameters:

_keyWidth The bit-width of the cipher key, which is 128, 192, or 256.
ciphertext Input block stream text to be decrypted, each block is 128 bits.
ciphertext_e End flag of block stream ciphertext, 1 bit.
cipherkey Input cipher key used in decryption, x bits for AES-x.
IV_strm Initialization vector for the fisrt iteration of AES decrypition, 128 bits.
plaintext Output decrypted block stream text, each block is 128 bits.
plaintext_e End flag of stream plaintext, 1 bit.

aesCfb128Encrypt

#include "xf_security/cfb.hpp"
template <unsigned int _keyWidth = 256>
void aesCfb128Encrypt (
    hls::stream <ap_uint <128>>& plaintext,
    hls::stream <bool>& plaintext_e,
    hls::stream <ap_uint <_keyWidth>>& cipherkey,
    hls::stream <ap_uint <128>>& initialization_vector,
    hls::stream <ap_uint <128>>& ciphertext,
    hls::stream <bool>& ciphertext_e
    )

aesCfb128Encrypt is CFB128 encryption mode with AES single block cipher.

The algorithm reference is : “Recommendation for Block Cipher Modes of Operation - Methods and Techniques” The implementation is modified for better performance.

Parameters:

_keyWidth The bit-width of the cipher key, which is 128, 192, or 256.
plaintext Input block stream text to be encrypted, each block is 128 bits.
plaintext_e End flag of block stream plaintext, 1 bit.
cipherkey Input cipher key used in encryption, x bits for AES-x.
initialization_vector Initialization vector for the fisrt iteration of AES encrypition, 128 bits.
ciphertext Output encrypted block stream text, each block is 128 bits.
ciphertext_e End flag of stream ciphertext, 1 bit.

aesCfb128Decrypt

#include "xf_security/cfb.hpp"
template <unsigned int _keyWidth = 256>
void aesCfb128Decrypt (
    hls::stream <ap_uint <128>>& ciphertext,
    hls::stream <bool>& ciphertext_e,
    hls::stream <ap_uint <_keyWidth>>& cipherkey,
    hls::stream <ap_uint <128>>& IV_strm,
    hls::stream <ap_uint <128>>& plaintext,
    hls::stream <bool>& plaintext_e
    )

aesCfb128Decrypt is CFB128 decryption mode with AES single block cipher.

The algorithm reference is : “Recommendation for Block Cipher Modes of Operation - Methods and Techniques” The implementation is modified for better performance.

Parameters:

_keyWidth The bit-width of the cipher key, which is 128, 192, or 256.
ciphertext Input block stream text to be decrypted, each block is 128 bits.
ciphertext_e End flag of block stream ciphertext, 1 bit.
cipherkey Input cipher key used in decryption, x bits for AES-x.
IV_strm Initialization vector for the fisrt iteration of AES decrypition, 128 bits.
plaintext Output decrypted block stream text, each block is 128 bits.
plaintext_e End flag of stream plaintext, 1 bit.

chacha20Imp

#include "xf_security/chacha20.hpp"
void chacha20Imp (
    hls::stream <ap_uint <256>>& keyStrm,
    hls::stream <ap_uint <128>>& counterNonceStrm,
    hls::stream <ap_uint <512>>& plainStrm,
    hls::stream <bool>& ePlainStrm,
    hls::stream <ap_uint <512>>& cipherStrm,
    hls::stream <bool>& eCipherStrm
    )

chacha20 is a function for stream ciphering

Parameters:

keyStrm initail key
counterNonceStm initial counter and nonce
plainStrm input plain text to be encrypted
ePlainStrm the end flag of plainStrm
cipherStrm output encrypted text
eCipherStrm the end flag of cipherStrm

aesCtrEncrypt

#include "xf_security/ctr.hpp"
template <unsigned int _keyWidth = 256>
void aesCtrEncrypt (
    hls::stream <ap_uint <128>>& plaintext,
    hls::stream <bool>& plaintext_e,
    hls::stream <ap_uint <_keyWidth>>& cipherkey,
    hls::stream <ap_uint <128>>& initialization_vector,
    hls::stream <ap_uint <128>>& ciphertext,
    hls::stream <bool>& ciphertext_e
    )

aesCtrEncrypt is CTR encryption mode with AES single block cipher.

The algorithm reference is : “Recommendation for Block Cipher Modes of Operation - Methods and Techniques” The implementation is modified for better performance.

Parameters:

_keyWidth The bit-width of the cipher key, which is 128, 192, or 256.
plaintext Input block stream text to be encrypted, each block is 128 bits.
plaintext_e End flag of block stream plaintext, 1 bit.
cipherkey Input cipher key used in encryption, x bits for AES-x.
initialization_vector Initialization vector for the fisrt iteration of AES encrypition, 128 bits.
ciphertext Output encrypted block stream text, 128 bits.
ciphertext_e End flag of block stream ciphertext, 1 bit.

aesCtrDecrypt

#include "xf_security/ctr.hpp"
template <unsigned int _keyWidth = 256>
void aesCtrDecrypt (
    hls::stream <ap_uint <128>>& ciphertext,
    hls::stream <bool>& ciphertext_e,
    hls::stream <ap_uint <_keyWidth>>& cipherkey,
    hls::stream <ap_uint <128>>& IV_strm,
    hls::stream <ap_uint <128>>& plaintext,
    hls::stream <bool>& plaintext_e
    )

aesCtrDecrypt is CTR decryption mode with AES single block cipher.

The algorithm reference is : “Recommendation for Block Cipher Modes of Operation - Methods and Techniques” The implementation is modified for better performance.

Parameters:

_keyWidth The bit-width of the cipher key, which is 128, 192, or 256.
ciphertext Input block stream text to be decrypted, each block is 128 bits.
ciphertext_e End flag of block stream ciphertext, 1 bit.
cipherkey Input cipher key used in decryption, x bits for AES-x.
IV_strm Initialization vector for the fisrt iteration of AES decrypition, 128 bits.
plaintext Output decrypted block stream text, each block is 128 bits.
plaintext_e End flag of block stream plaintext, 1 bit.

keySchedule

#include "xf_security/des.hpp"
static void keySchedule (
    ap_uint <64> key,
    ap_uint <48> subkeys [16]
    )

keySchedule is to schedule subkeys used in DES and 3DES

Parameters:

key input original key, 64 bits.
subkeys output subkeys in encryption or decryption.

aesEcbEncrypt

#include "xf_security/ecb.hpp"
template <unsigned int _keyWidth = 256>
void aesEcbEncrypt (
    hls::stream <ap_uint <128>>& plaintext,
    hls::stream <bool>& plaintext_e,
    hls::stream <ap_uint <_keyWidth>>& cipherkey,
    hls::stream <ap_uint <128>>& ciphertext,
    hls::stream <bool>& ciphertext_e
    )

aesEcbEncrypt is ECB encryption mode with AES single block cipher.

The algorithm reference is : “Recommendation for Block Cipher Modes of Operation - Methods and Techniques” The implementation is modified for better performance.

Parameters:

_keyWidth The bit-width of the cipher key, which is 128, 192, or 256.
plaintext Input block stream text to be encrypted, each block is 128 bits.
plaintext_e End flag of block stream plaintext, 1 bit.
cipherkey Input cipher key used in encryption, x bits for AES-x.
ciphertext Output encrypted block stream text, each block is 128 bits.
ciphertext_e End flag of block stream ciphertext, 1 bit.

aesEcbDecrypt

#include "xf_security/ecb.hpp"
template <unsigned int _keyWidth = 256>
void aesEcbDecrypt (
    hls::stream <ap_uint <128>>& ciphertext,
    hls::stream <bool>& ciphertext_e,
    hls::stream <ap_uint <_keyWidth>>& cipherkey,
    hls::stream <ap_uint <128>>& plaintext,
    hls::stream <bool>& plaintext_e
    )

aesEcbDecrypt is ECB decryption mode with AES single block cipher.

The algorithm reference is : “Recommendation for Block Cipher Modes of Operation - Methods and Techniques” The implementation is modified for better performance.

Parameters:

_keyWidth The bit-width of the cipher key, which is 128, 192, or 256.
ciphertext Input block stream to be decrypted, each block is 128 bits.
ciphertext_e End flag of block stream ciphertext, 1 bit.
cipherkey Input cipher key used in decryption, x bits for AES-x.
plaintext Output decrypted block stream text, each block is 128 bits.
plaintext_e End flag of block stream plaintext, 1 bit.

aesGctrEncrypt

#include "xf_security/gcm.hpp"
template <unsigned int _keyWidth = 256>
void aesGctrEncrypt (
    hls::stream <ap_uint <128>>& plaintext,
    hls::stream <ap_uint <64>>& plaintext_length,
    hls::stream <bool>& end_text_length,
    hls::stream <ap_uint <_keyWidth>>& cipherkey,
    hls::stream <ap_uint <96>>& IV_strm,
    hls::stream <ap_uint <128>>& H_strm,
    hls::stream <ap_uint <128>>& E_K_Y0_strm,
    hls::stream <bool>& end_length,
    hls::stream <ap_uint <128>>& ciphertext,
    hls::stream <ap_uint <64>>& ciphertext_length,
    hls::stream <ap_uint <128>>& ciphertext1,
    hls::stream <ap_uint <64>>& ciphertext_length1
    )

aesGctrEncrypt Encrypt plaintext to cihpertext.

The algorithm reference is: “IEEE Standard for Authenticated Encryption with Length Expansion for Storage Devices” The implementation is modified for better performance.

Parameters:

plaintext The plaintext stream.
plaintext_length Length of plaintext in bits.
end_text_length Flag to signal the end of the text length stream.
cipherkey The cipherkey, x-bit for AES-x.
IV_Strm Initialization vector.
H_strm The hash subkey passed onto genGMAC.
E_K_Y0_strm E(K,Y0) as specified in standard passed onto genGMAC.
end_length End flag passed onto genGMAC.
ciphertext The ciphertext stream to output port.
ciphertext_length Length of ciphertext in bits to output port.
ciphertext1 The ciphertext stream to genGMAC.
ciphertext_length1 Length of ciphertext in bits to genGMAC.

aesGctrDecrypt

#include "xf_security/gcm.hpp"
template <unsigned int _keyWidth = 256>
void aesGctrDecrypt (
    hls::stream <ap_uint <128>>& ciphertext,
    hls::stream <ap_uint <64>>& ciphertext_length,
    hls::stream <bool>& end_text_length,
    hls::stream <ap_uint <_keyWidth>>& cipherkey,
    hls::stream <ap_uint <96>>& IV_strm,
    hls::stream <ap_uint <128>>& H_strm,
    hls::stream <ap_uint <128>>& E_K_Y0_strm,
    hls::stream <bool>& end_length,
    hls::stream <ap_uint <128>>& ciphertext_out,
    hls::stream <ap_uint <64>>& ciphertext_length_out,
    hls::stream <ap_uint <128>>& plaintext,
    hls::stream <ap_uint <64>>& plaintext_length
    )

aesGctrDecrypt Decrypt ciphertext to plainrtext.

The algorithm reference is: “IEEE Standard for Authenticated Encryption with Length Expansion for Storage Devices” The implementation is modified for better performance.

Parameters:

ciphertext The ciphertext stream.
ciphertext_length Length of ciphertext in bits.
end_text_length Flag to signal the end of the text length stream.
cipherkey The cipherkey, x-bit for AES-x.
IV_Strm Initialization vector.
H_strm The hash subkey passed onto genGMAC.
E_K_Y0_strm E(K,Y0) as specified in standard passed onto genGMAC.
end_length End flag passed onto genGMAC.
ciphertext_out The ciphertext stream passed onto genGMAC.
ciphertext_length_out Length of ciphertext in bits passed onto genGMAC.
plaintext The plaintext stream.
plaintext_length Length of plaintext in bits.

aesGcmEncrypt

#include "xf_security/gcm.hpp"
template <unsigned int _keyWidth = 256>
void aesGcmEncrypt (
    hls::stream <ap_uint <128>>& plaintext,
    hls::stream <ap_uint <64>>& plaintext_length,
    hls::stream <ap_uint <_keyWidth>>& cipherkey,
    hls::stream <ap_uint <96>>& IV,
    hls::stream <ap_uint <128>>& AAD,
    hls::stream <ap_uint <64>>& AAD_length,
    hls::stream <bool>& end_length,
    hls::stream <ap_uint <128>>& ciphertext,
    hls::stream <ap_uint <64>>& ciphertext_length,
    hls::stream <ap_uint <128>>& tag,
    hls::stream <bool>& end_tag
    )

aesGcmEncrypt Top of GCM encryption mode with AES single block cipher.

The algorithm reference is : “IEEE Standard for Authenticated Encryption with Length Expansion for Storage Devices” The implementation is modified for better performance.

Parameters:

_keyWidth The bit-width of the cipher key, which is 128, 192, or 256.
plaintext Input block stream text to be encrypted, 128 bits.
plaintext_length Length of plaintext in bits.
cipherkey Input cipher key used in encryption, x bits for AES-x.
IV Initialization vector.
AAD Additional authenticated data for calculating the tag, 128 bits.
AAD_length Length of AAD in bits.
end__length Flag to signal the end of the text length stream.
ciphertext Output encrypted block stream text, 128 bits.
ciphertext_length Length of ciphertext in bits.
tag The MAC.
end_tag End flag for the MAC.

aesGcmDecrypt

#include "xf_security/gcm.hpp"
template <unsigned int _keyWidth = 256>
void aesGcmDecrypt (
    hls::stream <ap_uint <128>>& ciphertext,
    hls::stream <ap_uint <64>>& ciphertext_length,
    hls::stream <ap_uint <_keyWidth>>& cipherkey,
    hls::stream <ap_uint <96>>& IV,
    hls::stream <ap_uint <128>>& AAD,
    hls::stream <ap_uint <64>>& AAD_length,
    hls::stream <bool>& end_length,
    hls::stream <ap_uint <128>>& plaintext,
    hls::stream <ap_uint <64>>& plaintext_length,
    hls::stream <ap_uint <128>>& tag,
    hls::stream <bool>& end_tag
    )

aesGcmDecrypt Top of GCM decryption mode with AES single block cipher.

The algorithm reference is : “IEEE Standard for Authenticated Encryption with Length Expansion for Storage Devices” The implementation is modified for better performance.

Parameters:

ciphertext Input block stream text to be decrypted, 128 bits.
ciphertext_length Length of ciphertext in bits.
cipherkey Input cipher key used in decryption, x bits for AES-x.
IV Initialization vector.
AAD Additional authenticated data for calculating the tag, 128 bits.
AAD_length Length of AAD in bits.
end__length Flag to signal the end of the text length stream.
plaintext Output decrypted block stream text, 128 bits.
plaintext_length Length of plaintext in bits.
tag The MAC.
end_tag End flag for the MAC.

GF128_mult

#include "xf_security/gmac.hpp"
static void GF128_mult (
    ap_uint <128>& X,
    ap_int <128> AAD,
    ap_uint <128> Y [128]
    )

Optimized version of multiplication in GF(2^128)

Because in call of GF128_mult_origin within a loop, the input Y is fixed. So we pre-calculate Y^n in GF(2^128) with GF128_prepare(). This will reduce II in genGMAC from 23 to 1

Parameters:

X The first operand.
Y The second operand.
Z The product.

preGMAC

#include "xf_security/gmac.hpp"
template <unsigned int _keyWidth>
void preGMAC (
    hls::stream <ap_uint <_keyWidth>>& cipherkeyStrm,
    hls::stream <ap_uint <96>>& IVStrm,
    hls::stream <ap_uint <128>>& HStrm,
    hls::stream <ap_uint <128>>& EKY0Strm
    )

preGMAC generates H and E_K_Y0 based on AES block cipher.

The algorithm reference is: “IEEE Standard for Authenticated Encryption with Length Expansion for Storage Devices” The implementation is modified for less resource utilizations while having a reasonable latency.

Parameters:

_keyWidth The bit-width of the cipherkey.
cipherkeyStrm Input cipherkey, x bits for AES-x.
IVStrm Initialization vector for the fisrt iteration of AES encrypition.
HStrm The hash key.
EKY0Strm E(K, Y0) as specified in the standard.
lenPldStrm Length of the payload stream (hard-code to zero).

genGMAC

genGMAC overload (1)

#include "xf_security/gmac.hpp"
void genGMAC (
    hls::stream <ap_uint <128>>& AADStrm,
    hls::stream <ap_uint <64>>& lenAADStrm,
    hls::stream <ap_uint <128>>& pldStrm,
    hls::stream <ap_uint <64>>& lenPldStrm,
    hls::stream <ap_uint <128>>& HStrm,
    hls::stream <ap_uint <128>>& EKY0Strm,
    hls::stream <bool>& endLenStrm,
    hls::stream <ap_uint <128>>& tagStrm,
    hls::stream <bool>& endTagStrm
    )

genGMAC This function calculates the MAC using AAD and payload streams. This overload is used by GCM.

The algorithm reference is: “IEEE Standard for Authenticated Encryption with Length Expansion for Storage Devices” The implementation is modified for less resource utilizations while having a reasonable latency.

Parameters:

AADStrm Additional authenticated data stream.
lenAADStrm Length of AAD in bits.
pldStrm Payload stream.
lenPldStrm Length of the payload in bits.
HStrm The hash key.
EKY0Strm E(K, Y0) as specified in the standard.
endLenStrm Flag to signal the end of the length streams.
tagStrm The MAC.
endTagStrm Flag to signal the end of the MAC stream.

genGMAC overload (2)

#include "xf_security/gmac.hpp"
void genGMAC (
    hls::stream <ap_uint <128>>& AADStrm,
    hls::stream <ap_uint <64>>& lenAADStrm,
    hls::stream <ap_uint <128>>& HStrm,
    hls::stream <ap_uint <128>>& EKY0Strm,
    hls::stream <ap_uint <128>>& tagStrm
    )

genGMAC This function calculates the MAC using only AAD stream. This overload is used by GMAC.

The algorithm reference is: “IEEE Standard for Authenticated Encryption with Length Expansion for Storage Devices” The implementation is modified for less resource utilizations while having a reasonable latency.

Parameters:

AADStrm Additional authenticated data stream.
lenAADStrm Length of AAD in bits.
HStrm The hash key.
EKY0Strm E(K, Y0) as specified in the standard.
tagStrm The MAC.

gmacTop

#include "xf_security/gmac.hpp"
template <unsigned int _keyWidth>
void gmacTop (
    hls::stream <ap_uint <128>>& dataStrm,
    hls::stream <ap_uint <64>>& lenDataStrm,
    hls::stream <ap_uint <_keyWidth>>& cipherkeyStrm,
    hls::stream <ap_uint <96>>& IVStrm,
    hls::stream <ap_uint <128>>& tagStrm
    )

gmac The top of GMAC.

Galois Message Authentication Code (GMAC) is a mechanism to provide data origin authentication.

Parameters:

_keyWidth The bit-width of the cipherkey.
dataStrm Input text stream to be authenticated.
lenDataStrm The length of the data in bits.
cipherkeyStrm Input cihperkey to calculate the hash subkey and E(K,Y0).
IVStrm Initialization vector.
tagStrm The MAC stream.

preProcessing

#include "xf_security/md4.hpp"
static void preProcessing (
    hls::stream <ap_uint <32>>& msg_strm,
    hls::stream <ap_uint <64>>& len_strm,
    hls::stream <bool>& end_len_strm,
    hls::stream <blockType>& blk_strm,
    hls::stream <ap_uint <64>>& nblk_strm,
    hls::stream <bool>& end_nblk_strm
    )

Generate 512-bit processing blocks by padding and appending (pipeline).

The algorithm reference is : “The MD4 Message-Digest Algorithm”. The optimization goal of this function is to yield a 512-bit block per cycle.

Parameters:

msg_strm The message being hashed.
len_strm The message length in byte.
end_len_strm The flag to signal end of input message stream.
blk_strm The 512-bit hash block.
nblk_strm The number of hash block for this message.
end_nblk_strm End flag for number of hash block.

F

#include "xf_security/md4.hpp"
static ap_uint <32> F (
    ap_uint <32> x,
    ap_uint <32> y,
    ap_uint <32> z
    )

Perform function F as defined in standard.

The algorithm reference is : “The MD4 Message-Digest Algorithm”.

Parameters:

x The first 32-bit operand.
y The second 32-bit operand.
z The third 32-bit operand.

G

#include "xf_security/md4.hpp"
static ap_uint <32> G (
    ap_uint <32> x,
    ap_uint <32> y,
    ap_uint <32> z
    )

Perform function G as defined in standard.

The algorithm reference is : “The MD4 Message-Digest Algorithm”.

Parameters:

x The first 32-bit operand.
y The second 32-bit operand.
z The third 32-bit operand.

H

#include "xf_security/md4.hpp"
static ap_uint <32> H (
    ap_uint <32> x,
    ap_uint <32> y,
    ap_uint <32> z
    )

Perform function H as defined in standard.

The algorithm reference is : “The MD4 Message-Digest Algorithm”.

Parameters:

x The first 32-bit operand.
y The second 32-bit operand.
z The third 32-bit operand.

ROTL

#include "xf_security/md4.hpp"
template <unsigned int w>
ap_uint <w> ROTL (
    unsigned int n,
    ap_uint <w> x
    )

The implementation of rotate left (circular left shift) operation.

The implementation of rotate left (circular left shift) operation. The algorithm reference is : “Secure Hash Standard”, which published by NIST in February 2012.

The algorithm reference is : “The MD4 Message-Digest Algorithm”.

The algorithm reference is : “The MD5 Message-Digest Algorithm”.

Parameters:

w The bit width of input x, default value is 32.
n Number of bits for input x to be shifted.
x Word to be rotated.
w The bit width of input x, default value is 32.
n Number of bits for input x to be shifted.
x Word to be rotated.
w The bit width of input x, default value is 32.
n Number of bits for input x to be shifted.
x Word to be rotated.

MD4Round1

#include "xf_security/md4.hpp"
static void MD4Round1 (
    ap_uint <32>& a,
    ap_uint <32> b,
    ap_uint <32> c,
    ap_uint <32> d,
    ap_uint <32> X,
    unsigned int s
    )

The implementation of the function defined in round 1.

The algorithm reference is : “The MD4 Message-Digest Algorithm”. The operation is defined as : a = (a + F(b, c, d) + X[k]) <<< s.

Parameters:

a The first 32-bit operand.
b The second 32-bit operand.
c The third 32-bit operand.
d The fourth 32-bit operand.
X The specific message word.
s Number of bits to be shifted.

MD4Round2

#include "xf_security/md4.hpp"
static void MD4Round2 (
    ap_uint <32>& a,
    ap_uint <32> b,
    ap_uint <32> c,
    ap_uint <32> d,
    ap_uint <32> X,
    unsigned int s
    )

The implementation of the function defined in round 2.

The algorithm reference is : “The MD4 Message-Digest Algorithm”. The operation is defined as : a = (a + G(b, c, d) + X[k] + 0x5a827999) <<< s

Parameters:

a The first 32-bit operand.
b The second 32-bit operand.
c The third 32-bit operand.
d The fourth 32-bit operand.
X The specific message word.
s Number of bits to be shifted.

MD4Round3

#include "xf_security/md4.hpp"
static void MD4Round3 (
    ap_uint <32>& a,
    ap_uint <32> b,
    ap_uint <32> c,
    ap_uint <32> d,
    ap_uint <32> X,
    unsigned int s
    )

The implementation of the function defined in round 3.

The algorithm reference is : “The MD4 Message-Digest Algorithm”. The operation is defined as : a = (a + H(b, c, d) + X[k] + 0x6ed9eba1) <<< s

Parameters:

a The first 32-bit operand.
b The second 32-bit operand.
c The third 32-bit operand.
d The fourth 32-bit operand.
X The specific message word.
s Number of bits to be shifted.

MD4Digest

#include "xf_security/md4.hpp"
static void MD4Digest (
    hls::stream <blockType>& blk_strm,
    hls::stream <ap_uint <64>>& nblk_strm,
    hls::stream <bool>& end_nblk_strm,
    hls::stream <ap_uint <128>>& digest_strm,
    hls::stream <bool>& end_digest_strm
    )

The implementation of the digest part of MD4.

The algorithm reference is : “The MD4 Message-Digest Algorithm”. The optimization goal of this function is for better performance.

Parameters:

blk_strm The 512-bit hash block.
nblk_strm The number of hash block for this message.
end_nblk_strm End flag for number of hash block.
digest_strm The digest (fingerprint) stream.
end_digest_strm Flag to signal the end of the result.

I

#include "xf_security/md5.hpp"
static ap_uint <32> I (
    ap_uint <32> x,
    ap_uint <32> y,
    ap_uint <32> z
    )

Perform function I as defined in standard.

The algorithm reference is : “The MD5 Message-Digest Algorithm”.

Parameters:

x The first 32-bit operand.
y The second 32-bit operand.
z The third 32-bit operand.

MD5Round1

#include "xf_security/md5.hpp"
static void MD5Round1 (
    ap_uint <32>& a,
    ap_uint <32> b,
    ap_uint <32> c,
    ap_uint <32> d,
    ap_uint <32> X,
    ap_uint <32> T,
    unsigned int s
    )

The implementation of the function defined in round 1.

The algorithm reference is : “The MD5 Message-Digest Algorithm”. The operation is defined as : a = b + ((a + F(b, c, d) + X + T) <<< s).

Parameters:

a The first 32-bit operand.
b The second 32-bit operand.
c The third 32-bit operand.
d The fourth 32-bit operand.
X The specific message word.
T the specific sine value.
s Number of bits to be shifted.

MD5Round2

#include "xf_security/md5.hpp"
static void MD5Round2 (
    ap_uint <32>& a,
    ap_uint <32> b,
    ap_uint <32> c,
    ap_uint <32> d,
    ap_uint <32> X,
    ap_uint <32> T,
    unsigned int s
    )

The implementation of the function defined in round 2.

The algorithm reference is : “The MD5 Message-Digest Algorithm”. The operation is defined as : a = b + ((a + G(b, c, d) + X + T) <<< s).

Parameters:

a The first 32-bit operand.
b The second 32-bit operand.
c The third 32-bit operand.
d The fourth 32-bit operand.
X The specific message word.
T the specific sine value.
s Number of bits to be shifted.

MD5Round3

#include "xf_security/md5.hpp"
static void MD5Round3 (
    ap_uint <32>& a,
    ap_uint <32> b,
    ap_uint <32> c,
    ap_uint <32> d,
    ap_uint <32> X,
    ap_uint <32> T,
    unsigned int s
    )

The implementation of the function defined in round 3.

The algorithm reference is : “The MD5 Message-Digest Algorithm”. The operation is defined as : a = b + ((a + H(b, c, d) + X + T) <<< s).

Parameters:

a The first 32-bit operand.
b The second 32-bit operand.
c The third 32-bit operand.
d The fourth 32-bit operand.
X The specific message word.
T the specific sine value.
s Number of bits to be shifted.

MD5Round4

#include "xf_security/md5.hpp"
static void MD5Round4 (
    ap_uint <32>& a,
    ap_uint <32> b,
    ap_uint <32> c,
    ap_uint <32> d,
    ap_uint <32> X,
    ap_uint <32> T,
    unsigned int s
    )

The implementation of the function defined in round 4.

The algorithm reference is : “The MD5 Message-Digest Algorithm”. The operation is defined as : a = b + ((a + I(b, c, d) + X + T) <<< s).

Parameters:

a The first 32-bit operand.
b The second 32-bit operand.
c The third 32-bit operand.
d The fourth 32-bit operand.
X The specific message word.
T the specific sine value.
s Number of bits to be shifted.

MD5Digest

#include "xf_security/md5.hpp"
static void MD5Digest (
    hls::stream <blockType>& blk_strm,
    hls::stream <ap_uint <64>>& nblk_strm,
    hls::stream <bool>& end_nblk_strm,
    hls::stream <ap_uint <128>>& digest_strm,
    hls::stream <bool>& end_digest_strm
    )

The implementation of the digest part of MD5.

The algorithm reference is : “The MD5 Message-Digest Algorithm”. The optimization goal of this function is for better performance.

Parameters:

blk_strm The 512-bit hash block.
nblk_strm The number of hash block for this message.
end_nblk_strm End flag for number of hash block.
digest_strm The digest (fingerprint) stream.
end_digest_strm Flag to signal the end of the result.

productMod

#include "xf_security/modular.hpp"
template <int N>
ap_uint <N> productMod (
    ap_uint <N> opA,
    ap_uint <N> opB,
    ap_uint <N> opM
    )

return (opA * opB) mod opM

Parameters:

N bit width of opA, opB and opM
opA Product input, should be less than opM
opB Product input, should be less than opM
opM Modulus, should be larger than 2^(N-1)

addMod

#include "xf_security/modular.hpp"
template <int N>
ap_uint <N> addMod (
    ap_uint <N> opA,
    ap_uint <N> opB,
    ap_uint <N> opM
    )

return (opA + opB) mod opM

Parameters:

N bit width of opA, opB and opM
opA Product input, should be less than opM
opB Product input, should be less than opM
opM Modulus

subMod

#include "xf_security/modular.hpp"
template <int N>
ap_uint <N> subMod (
    ap_uint <N> opA,
    ap_uint <N> opB,
    ap_uint <N> opM
    )

return (opA - opB) mod opM

Parameters:

N bit width of opA, opB and opM
opA Product input, should be less than opM
opB Product input, should be less than opM
opM Modulus

monInv

#include "xf_security/modular.hpp"
template <int N>
ap_uint <N> monInv (
    ap_uint <N> opA,
    ap_uint <N> opM
    )

return montgomery inverse of opA Reference: “The Montgomery Modular Inverse - Revisited” by E Savas, CK Koç

Parameters:

N bit width of opA and opM
opA Input of modular inverse.
opM Modulus of modular inverse.

modularInv

#include "xf_security/modular.hpp"
template <int N>
ap_uint <N> modularInv (
    ap_uint <N> opA,
    ap_uint <N> opM
    )

return modular inverse of opA Reference: “The Montgomery Modular Inverse - Revisited” by E Savas, CK Koç

Parameters:

N bit width of opA and opM, opM should no less than 2^(N-1)
opA Input of modular inverse. opA should be non-zero, might need extra checking
opM Modulus of modular inverse.

aesOfbEncrypt

#include "xf_security/ofb.hpp"
template <unsigned int _keyWidth = 256>
void aesOfbEncrypt (
    hls::stream <ap_uint <128>>& plaintext,
    hls::stream <bool>& plaintext_e,
    hls::stream <ap_uint <_keyWidth>>& cipherkey,
    hls::stream <ap_uint <128>>& initialization_vector,
    hls::stream <ap_uint <128>>& ciphertext,
    hls::stream <bool>& ciphertext_e
    )

aesOfbEncrypt is OFB encryption mode with AES single block cipher.

The algorithm reference is : “Recommendation for Block Cipher Modes of Operation - Methods and Techniques” The implementation is modified for better performance.

Parameters:

_keyWidth The bit-width of the cipher key, which is 128, 192, or 256.
plaintext Input block stream text to be encrypted, each block is 128 bits.
plaintext_e End flag of block stream plaintext, 1 bit.
cipherkey Input cipher key used in encryption, x bits for AES-x.
initialization_vector Initialization vector for the fisrt iteration of AES encrypition, 128 bits.
ciphertext Output encrypted block stream text, each block is 128 bits.
ciphertext_e End flag of block stream ciphertext, 1 bit.

aesOfbDecrypt

#include "xf_security/ofb.hpp"
template <unsigned int _keyWidth = 256>
void aesOfbDecrypt (
    hls::stream <ap_uint <128>>& ciphertext,
    hls::stream <bool>& ciphertext_e,
    hls::stream <ap_uint <_keyWidth>>& cipherkey,
    hls::stream <ap_uint <128>>& IV_strm,
    hls::stream <ap_uint <128>>& plaintext,
    hls::stream <bool>& plaintext_e
    )

aesOfbDecrypt is OFB decryption mode with AES single block cipher.

The algorithm reference is : “Recommendation for Block Cipher Modes of Operation - Methods and Techniques” The implementation is modified for better performance.

Parameters:

_keyWidth The bit-width of the cipher key, which is 128, 192, or 256.
ciphertext Input block stream to be decrypted, each block is 128 bits.
ciphertext_e End flag of block stream ciphertext, 1 bit.
cipherkey Input cipher key used in decryption, x bits for AES-x.
IV_strm Initialization vector for the fisrt iteration of AES decrypition, 128 bits.
plaintext Output decrypted block stream text, each block is 128 bits.
plaintext_e End flag of block stream plaintext, 1 bit.

multOperator

#include "xf_security/poly1305.hpp"
ap_uint <260> multOperator (
    ap_uint <132> A,
    ap_uint <128> B
    )

The implementation of large bit-width multiplication, the result is A * B. The optimization goal of this function to improve timing.

Parameters:

A The input multiplicand.
B The input multiplier.

Returns:

The output product.

resOperator

#include "xf_security/poly1305.hpp"
ap_uint <132> resOperator (ap_uint <260> A)

The implementation of large bit-width Module Operation, the result is A % 2^130-5. The optimization goal of this function to improve timing.

Parameters:

A The input parameter.

Returns:

The output result.

poly1305Imp

#include "xf_security/poly1305.hpp"
void poly1305Imp (
    ap_uint <132>& accValue,
    ap_uint <256> keyValue,
    ap_uint <128> payload,
    ap_uint <32> lenByte,
    ap_uint <128>& tagValue
    )

The implementation of poly1305.

Parameters:

accValue The accumulator’s value, initial value is 0, followed by the last output.
keyValue Corresponding message key
payload For a massage, input block stream text, 128 bits per block, less than 128 bits, high padding 0
lenByte Length of a block of payload in byte.
tagValue return a 16-byte tag to to authenticate the message.

rc4Imp

#include "xf_security/rc4.hpp"
static void rc4Imp (
    hls::stream <ap_uint <8>>& keyStrm,
    hls::stream <bool>& eKeyStrm,
    hls::stream <ap_uint <8>>& plainStream,
    hls::stream <bool>& ePlainStream,
    hls::stream <ap_uint <8>>& cipherStream,
    hls::stream <bool>& eCipherStream
    )

Rc_4 is the basic function for stream ciphering keyLength defined as the number of bytes in the key and can be in the range 1<= keylength <=256, typically between 5 and 16, corresponding to a key length of 40-128 bits.

Parameters:

keyStrm initail key
eKeyStrm end flag of keyStrm
plaintStrm input plain text to be encrypted
ePlaintStrm the end flag of plaintStrm
cipherStrm output encrypted text
eCipherStrm the end flag of cipherStrm

Ch

#include "xf_security/sha1.hpp"
template <unsigned int w>
ap_uint <w> Ch (
    ap_uint <w> x,
    ap_uint <w> y,
    ap_uint <w> z
    )

The implementation of Ch(x,y,z), the sequence of logical functions of SHA-1 where 0 <= t <= 19. The algorithm reference is : “Secure Hash Standard”, which published by NIST in February 2012.

The implementation of Ch(x,y,z). The algorithm reference is : “Secure Hash Standard”, which published by NIST in February 2012.

Parameters:

w The bit width of input x, y, and z, default value is 32.
x The first w-bit input word.
y The second w-bit input word.
z The third w-bit input word.
w The bit width of input x, y, and z, default value is 64.
x The first w-bit input word.
y The second w-bit input word.
z The third w-bit input word.

Parity

#include "xf_security/sha1.hpp"
template <unsigned int w>
ap_uint <w> Parity (
    ap_uint <w> x,
    ap_uint <w> y,
    ap_uint <w> z
    )

The implementation of Parity(x,y,z), the sequence of logical functions of SHA-1 where 20 <= t <= 39, and 60 <= t <= 79. The algorithm reference is : “Secure Hash Standard”, which published by NIST in February 2012.

Parameters:

w The bit width of input x, y, and z, default value is 32.
x The first w-bit input word.
y The second w-bit input word.
z The third w-bit input word.

Maj

#include "xf_security/sha1.hpp"
template <unsigned int w>
ap_uint <w> Maj (
    ap_uint <w> x,
    ap_uint <w> y,
    ap_uint <w> z
    )

The implementation of Maj(x,y,z), the sequence of logical functions of SHA-1 where 40 <= t <= 59. The algorithm reference is : “Secure Hash Standard”, which published by NIST in February 2012.

The implementation of Maj(x,y,z). The algorithm reference is : “Secure Hash Standard”, which published by NIST in February 2012.

Parameters:

w The bit width of input x, y, and z, default value is 32.
x The first w-bit input word.
y The second w-bit input word.
z The third w-bit input word.
w The bit width of input x, y, and z, default value is 64.
x The first w-bit input word.
y The second w-bit input word.
z The third w-bit input word.

generateMsgSchedule

#include "xf_security/sha1.hpp"
template <unsigned int w>
void generateMsgSchedule (
    hls::stream <blockType>& blk_strm,
    hls::stream <ap_uint <64>>& nblk_strm1,
    hls::stream <bool>& end_nblk_strm1,
    hls::stream <ap_uint <w>>& w_strm,
    hls::stream <ap_uint <64>>& nblk_strm2,
    hls::stream <bool>& end_nblk_strm2
    )

Generate message schedule W (80 words) in stream. The algorithm reference is : “Secure Hash Standard”, which published by NIST in February 2012.

Parameters:

w The bit width of message schedule W which defined in the standard.
blk_strm Message block stream.
nblk_strm1 Number of message block stream.
end_nblk_strm1 End flag for number of message block stream.
w_strm The message schedule in stream.
nblk_strm2 Number of message block stream.
end_nblk_strm2 End flag for number of message block stream.

SHA1Digest

#include "xf_security/sha1.hpp"
template <unsigned int w>
void SHA1Digest (
    hls::stream <ap_uint <w>>& w_strm,
    hls::stream <ap_uint <64>>& nblk_strm,
    hls::stream <bool>& end_nblk_strm,
    hls::stream <ap_uint <5*w>>& digest_strm,
    hls::stream <bool>& end_digest_strm
    )

This function performs the computation of the secure hash algorithm.

The algorithm reference is : “Secure Hash Standard”, which published by NIST in February 2012. The implementation is modified for better performance.

Parameters:

w The bit width of each input message word, default value is 32.
w_strm Message schedule stream.
nblk_strm Number of message block stream.
end_nblk_strm End flag for number of message block stream.
digest_strm Output digest stream.
end_digest_strm End flag for output digest stream.

preProcessing

preProcessing overload (1)

#include "xf_security/sha224_256.hpp"
void preProcessing (
    hls::stream <ap_uint <32>>& msg_strm,
    hls::stream <ap_uint <64>>& len_strm,
    hls::stream <bool>& end_len_strm,
    hls::stream <SHA256Block>& blk_strm,
    hls::stream <uint64_t>& nblk_strm,
    hls::stream <bool>& end_nblk_strm
    )

Generate 512bit processing blocks for SHA224/SHA256 (pipeline) with const width. The performance goal of this function is to yield a 512b block per cycle.

Parameters:

msg_strm the message being hashed.
len_strm the message length in byte.
end_len_strm that flag to signal end of input.
blk_strm the 512-bit hash block.
nblk_strm the number of hash block for this message.
end_nblk_strm end flag for number of hash block.

preProcessing overload (2)

#include "xf_security/sha224_256.hpp"
void preProcessing (
    hls::stream <ap_uint <64>>& msg_strm,
    hls::stream <ap_uint <64>>& len_strm,
    hls::stream <bool>& end_len_strm,
    hls::stream <SHA256Block>& blk_strm,
    hls::stream <uint64_t>& nblk_strm,
    hls::stream <bool>& end_nblk_strm
    )

Generate 512bit processing blocks for SHA224/SHA256 (pipeline) with const width. The performance goal of this function is to yield a 512b block per cycle.

Parameters:

msg_strm the message being hashed.
len_strm the message length in byte.
end_len_strm that flag to signal end of input.
blk_strm the 512-bit hash block.
nblk_strm the number of hash block for this message.
end_nblk_strm end flag for number of hash block.

sha256Digest

#include "xf_security/sha224_256.hpp"
template <int h_width>
void sha256Digest (
    hls::stream <uint64_t>& nblk_strm,
    hls::stream <bool>& end_nblk_strm,
    hls::stream <uint32_t>& w_strm,
    hls::stream <ap_uint <h_width>>& hash_strm,
    hls::stream <bool>& end_hash_strm
    )

Digest message blocks and emit final hash.

Parameters:

h_width the hash width(type).
nblk_strm number of message block.
end_nblk_strm end flag for number of message block.
hash_strm the hash result stream.
end_hash_strm end flag for hash result.

sha256_top

#include "xf_security/sha224_256.hpp"
template <
    int m_width,
    int h_width
    >
void sha256_top (
    hls::stream <ap_uint <m_width>>& msg_strm,
    hls::stream <ap_uint <64>>& len_strm,
    hls::stream <bool>& end_len_strm,
    hls::stream <ap_uint <h_width>>& hash_strm,
    hls::stream <bool>& end_hash_strm
    )

SHA-256/224 implementation top overload for ap_uint input.

Parameters:

m_width the input message stream width.
h_width the output hash stream width.
msg_strm the message being hashed.
len_strm the length message being hashed in byte.
end_len_strm end flag stream of input, one per message.
hash_strm the result.
end_hash_strm end falg stream of output, one per hash.

ROTL

#include "xf_security/sha3.hpp"
template <unsigned int w = 64>
ap_uint <w> ROTL (
    ap_uint <w> x,
    unsigned int n
    )

The implementation of rotate left (circular left shift) operation. The algorithm reference is : “SHA-3 Standard : Permutation-Based Hash and Extendable-Output Functions”.

Parameters:

w The bit width of input x, default value is 64.
n Number of bits for input x to be shifted.
x Word to be rotated.

KECCAK_f

#include "xf_security/sha3.hpp"
static void KECCAK_f (ap_uint <64> stateArray [25])

The implementation of KECCAK-f permutation function.

The algorithm reference is : “SHA-3 Standard : Permutation-Based Hash and Extendable-Output Functions”. The implementation is modified for better performance.

Parameters:

stateArray The 5*5*64 state array defined in standard.

sha3Digest

#include "xf_security/sha3.hpp"
template <unsigned int hashLen = 32>
void sha3Digest (
    hls::stream <ap_uint <64>>& msgStrm,
    hls::stream <ap_uint <128>>& msgLenStrm,
    hls::stream <bool>& endMsgLenStrm,
    hls::stream <ap_uint <8*hashLen>>& digestStrm,
    hls::stream <bool>& endDigestStrm
    )

This function performs the computation of SHA-3.

The algorithm reference is : “SHA-3 Standard : Permutation-Based Hash and Extendable-Output Functions”. The implementation is modified for better performance.

Parameters:

hashLen The width of the digest in byte, default value is 32 (SHA3-256).
msgStrm The message being hashed.
msgLenStrm Message length in byte.
endMsgLenStrm The flag to signal end of input message stream.
digestStrm Output digest stream.
endDigestStrm End flag for output digest stream.

shakeXOF

#include "xf_security/sha3.hpp"
template <unsigned int hashLen = 16>
void shakeXOF (
    hls::stream <ap_uint <64>>& msgStrm,
    hls::stream <ap_uint <128>>& msgLenStrm,
    hls::stream <bool>& endMsgLenStrm,
    hls::stream <ap_uint <8*hashLen>>& digestStrm,
    hls::stream <bool>& endDigestStrm
    )

This function performs the computation of SHAKE.

The algorithm reference is : “SHA-3 Standard : Permutation-Based Hash and Extendable-Output Functions”. The implementation is modified for better performance.

Parameters:

hashLen The width of the digest in byte, default value is 16 (SHAKE-128).
msgStrm The message being hashed.
msgLenStrm Message length in byte.
endMsgLenStrm The flag to signal end of input message stream.
digestStrm Output digest stream.
endDigestStrm End flag for output digest stream.

preProcessing

#include "xf_security/sha512_t.hpp"
template <unsigned int w>
static void preProcessing (
    hls::stream <ap_uint <w>>& msg_strm,
    hls::stream <ap_uint <128>>& len_strm,
    hls::stream <bool>& end_len_strm,
    hls::stream <blockType>& blk_strm,
    hls::stream <ap_uint <128>>& nblk_strm,
    hls::stream <bool>& end_nblk_strm
    )

Generate 1024-bit processing blocks by padding and appending (pipeline).

The algorithm reference is : “Secure Hash Standard”, which published by NIST in February 2012. The optimization goal of this function is to yield a 1024-bit block per cycle.

Parameters:

w The bit width of each input message word, default value is 64.
msg_strm The message being hashed.
len_strm The message length in byte.
end_len_strm The flag to signal end of input message stream.
blk_strm The 1024-bit hash block.
nblk_strm The number of hash block for this message.
end_nblk_strm End flag for number of hash block.

SHR

#include "xf_security/sha512_t.hpp"
template <unsigned int w>
ap_uint <w> SHR (
    unsigned int n,
    ap_uint <w> x
    )

The implementation of right shift operation. The algorithm reference is : “Secure Hash Standard”, which published by NIST in February 2012.

Parameters:

w The bit width of input x, default value is 64.
n Number of bits for input x to be shifted.
x Word to be shifted.

ROTR

#include "xf_security/sha512_t.hpp"
template <unsigned int w>
ap_uint <w> ROTR (
    unsigned int n,
    ap_uint <w> x
    )

The implementation of rotate right (circular right shift) operation. The algorithm reference is : “Secure Hash Standard”, which published by NIST in February 2012.

Parameters:

w The bit width of input x, default value is 64.
n Number of bits for input x to be shifted.
x Word to be rotated.

BSIG0

#include "xf_security/sha512_t.hpp"
template <unsigned int w>
ap_uint <w> BSIG0 (ap_uint <w> x)

The implementation of upper-case letter sigma 0. The algorithm reference is : “Secure Hash Standard”, which published by NIST in February 2012.

Parameters:

w The bit width of input x, default value is 64.
x The operand.

BSIG1

#include "xf_security/sha512_t.hpp"
template <unsigned int w>
ap_uint <w> BSIG1 (ap_uint <w> x)

The implementation of upper-case letter sigma 1. The algorithm reference is : “Secure Hash Standard”, which published by NIST in February 2012.

Parameters:

w The bit width of input x, default value is 64.
x The operand.

SSIG0

#include "xf_security/sha512_t.hpp"
template <unsigned int w>
ap_uint <w> SSIG0 (ap_uint <w> x)

The implementation of lower-case letter sigma 0. The algorithm reference is : “Secure Hash Standard”, which published by NIST in February 2012.

Parameters:

w The bit width of input x, default value is 64.
x The operand.

SSIG1

#include "xf_security/sha512_t.hpp"
template <unsigned int w>
ap_uint <w> SSIG1 (ap_uint <w> x)

The implementation of lower-case letter sigma 1. The algorithm reference is : “Secure Hash Standard”, which published by NIST in February 2012.

Parameters:

w The bit width of input x, default value is 64.
x The operand.

dup_strm

#include "xf_security/sha512_t.hpp"
template <unsigned int w>
void dup_strm (
    hls::stream <ap_uint <w>>& in_strm,
    hls::stream <bool>& in_e_strm,
    hls::stream <ap_uint <w>>& out1_strm,
    hls::stream <bool>& out1_e_strm,
    hls::stream <ap_uint <w>>& out2_strm,
    hls::stream <bool>& out2_e_strm
    )

Duplicate 1 input stream to 2 output streams.

Parameters:

w The bit width of the streams.
in_strm Input stream to be duplicated.
in_e_strm End flag of input stream.
out1_strm The first output stream.
out1_e_strm End flag of the first output stream.
out2_strm The second output stream.
out2_e_strm End flag of the second output stream.

generateMsgSchedule

#include "xf_security/sha512_t.hpp"
template <unsigned int w>
void generateMsgSchedule (
    hls::stream <blockType>& blk_strm,
    hls::stream <ap_uint <128>>& nblk_strm,
    hls::stream <bool>& end_nblk_strm,
    hls::stream <ap_uint <w>>& w_strm
    )

Generate message schedule W (80 words) in stream. The algorithm reference is : “Secure Hash Standard”, which published by NIST in February 2012.

Parameters:

w The bit width of message schedule W which defined in the standard, default value is 64.
blk_strm Message block stream.
nblk_strm Number of message block stream.
end_nblk_strm End flag for number of message block stream.
w_strm The message schedule in stream.

SHA512Digest

#include "xf_security/sha512_t.hpp"
template <
    unsigned int w,
    unsigned int hash_width
    >
void SHA512Digest (
    hls::stream <ap_uint <w>>& w_strm,
    hls::stream <ap_uint <128>>& nblk_strm,
    hls::stream <bool>& end_nblk_strm,
    hls::stream <ap_uint <hash_width>>& digest_strm,
    hls::stream <bool>& end_digest_strm
    )

This function performs the computation of SHA-512.

The algorithm reference is : “Secure Hash Standard”, which published by NIST in February 2012. The implementation is modified for better performance.

Parameters:

w The bit width of each input message word, default value is 64.
hash_width The bit width of hash width, which depends on specific algorithm.
w_strm Message schedule stream.
nblk_strm Number of message block stream.
end_nblk_strm End flag for number of message block stream.
digest_strm Output digest stream.
end_digest_strm End flag for output digest stream.

sha512Top

#include "xf_security/sha512_t.hpp"
template <
    unsigned int w,
    unsigned int hash_width
    >
void sha512Top (
    hls::stream <ap_uint <w>>& msg_strm,
    hls::stream <ap_uint <128>>& len_strm,
    hls::stream <bool>& end_len_strm,
    hls::stream <ap_uint <hash_width>>& digest_strm,
    hls::stream <bool>& end_digest_strm
    )

Top function of SHA-512.

The algorithm reference is : “Secure Hash Standard”, which published by NIST in February 2012. The implementation dataflows the pre-processing part and message digest part.

Parameters:

w The bit width of each input message word, default value is 64.
hash_width The bit width of hash width, which depends on specific algorithm.
msg_strm The message being hashed.
len_strm The message length in byte.
end_len_strm The flag to signal end of input message stream.
digest_strm Output digest stream.
end_digest_strm End flag for output digest stream.

aesXtsEncrypt

#include "xf_security/xts.hpp"
template <unsigned int _keyWidth = 256>
void aesXtsEncrypt (
    hls::stream <ap_uint <128>>& plaintext_strm,
    hls::stream <bool>& plaintext_e_strm,
    hls::stream <ap_uint <64>>& len_strm,
    hls::stream <ap_uint <_keyWidth>>& cipherkey_strm,
    hls::stream <ap_uint <128>>& initialization_vector_strm,
    hls::stream <ap_uint <128>>& ciphertext_strm,
    hls::stream <bool>& ciphertext_e_strm
    )

aesXtsEncrypt is XTS encryption mode with AES single block cipher.

The algorithm reference is : “IEEE Standard for Cryptographic Protection of Data on Block-Oriented Storage Devices” The implementation is optimized for better performance in FPGA.

Parameters:

_keyWidth The bit-width of the cipher key, which is 128, 192, or 256.
plaintext_strm Input block stream text to be encrypted, each block is 128 bits.
plaintext_e_strm End flag of block stream plaintext, 1 bit.
len_strm Total length of plaintext in bit, 64 bits.
cipherkey_strm Input two cipher key used in encryption, x bits for AES-x.
initialization_vector_strm Initialization vector for the fisrt iteration of AES encrypition, 128 bits.
ciphertext_strm Output encrypted block stream text, 128 bits.
ciphertext_e_strm End flag of stream ciphertext, 1 bit.

aesXtsDecrypt

#include "xf_security/xts.hpp"
template <unsigned int _keyWidth = 256>
void aesXtsDecrypt (
    hls::stream <ap_uint <128>>& ciphertext_strm,
    hls::stream <bool>& ciphertext_e_strm,
    hls::stream <ap_uint <64>>& len_strm,
    hls::stream <ap_uint <_keyWidth>>& cipherkey_strm,
    hls::stream <ap_uint <128>>& initialization_vector_strm,
    hls::stream <ap_uint <128>>& plaintext_strm,
    hls::stream <bool>& plaintext_e_strm
    )

aesXtsDecrypt is XTS decryption mode with AES single block cipher.

The algorithm reference is : “IEEE Standard for Cryptographic Protection of Data on Block-Oriented Storage Devices” The implementation is optimized for better performance in FPGA.

Parameters:

_keyWidth The bit-width of the cipher key, which is 128, 192, or 256.
ciphertext_strm Input block stream text to be decrypted, each block is 128 bits.
ciphertext_e_strm End flag of block stream ciphertext, 1 bit.
len_strm Total length of plaintext in bit, 64 bits.
cipherkey_strm Input two cipher key used in decryption, x bits for AES-x.
initialization_vector_strm Initialization vector for the fisrt iteration of AES encrypition, 128 bits.
plaintext_strm Output decrypted block stream text, each block is 128 bits.
plaintext_e_strm End flag of block stream plaintext, 1 bit.