iPXE
Functions
ecb.c File Reference

Electronic codebook (ECB) More...

#include <assert.h>
#include <ipxe/crypto.h>
#include <ipxe/ecb.h>

Go to the source code of this file.

Functions

 FILE_LICENCE (GPL2_OR_LATER_OR_UBDL)
 
void ecb_encrypt (void *ctx, const void *src, void *dst, size_t len, struct cipher_algorithm *raw_cipher)
 Encrypt data. More...
 
void ecb_decrypt (void *ctx, const void *src, void *dst, size_t len, struct cipher_algorithm *raw_cipher)
 Decrypt data. More...
 

Detailed Description

Electronic codebook (ECB)

Definition in file ecb.c.

Function Documentation

◆ FILE_LICENCE()

FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL  )

◆ ecb_encrypt()

void ecb_encrypt ( void *  ctx,
const void *  src,
void *  dst,
size_t  len,
struct cipher_algorithm raw_cipher 
)

Encrypt data.

Parameters
ctxContext
srcData to encrypt
dstBuffer for encrypted data
lenLength of data
raw_cipherUnderlying cipher algorithm

Definition at line 45 of file ecb.c.

46  {
47  size_t blocksize = raw_cipher->blocksize;
48 
49  assert ( ( len % blocksize ) == 0 );
50 
51  while ( len ) {
52  cipher_encrypt ( raw_cipher, ctx, src, dst, blocksize );
53  dst += blocksize;
54  src += blocksize;
55  len -= blocksize;
56  }
57 }
size_t blocksize
Block size.
Definition: crypto.h:60
static const void * src
Definition: string.h:47
struct golan_eq_context ctx
Definition: CIB_PRM.h:28
#define cipher_encrypt(cipher, ctx, src, dst, len)
Definition: crypto.h:233
assert((readw(&hdr->flags) &(GTF_reading|GTF_writing))==0)
uint32_t len
Length.
Definition: ena.h:14

References assert(), cipher_algorithm::blocksize, cipher_encrypt, ctx, len, and src.

◆ ecb_decrypt()

void ecb_decrypt ( void *  ctx,
const void *  src,
void *  dst,
size_t  len,
struct cipher_algorithm raw_cipher 
)

Decrypt data.

Parameters
ctxContext
srcData to decrypt
dstBuffer for decrypted data
lenLength of data
raw_cipherUnderlying cipher algorithm

Definition at line 68 of file ecb.c.

69  {
70  size_t blocksize = raw_cipher->blocksize;
71 
72  assert ( ( len % blocksize ) == 0 );
73 
74  while ( len ) {
75  cipher_decrypt ( raw_cipher, ctx, src, dst, blocksize );
76  dst += blocksize;
77  src += blocksize;
78  len -= blocksize;
79  }
80 }
size_t blocksize
Block size.
Definition: crypto.h:60
static const void * src
Definition: string.h:47
struct golan_eq_context ctx
Definition: CIB_PRM.h:28
assert((readw(&hdr->flags) &(GTF_reading|GTF_writing))==0)
#define cipher_decrypt(cipher, ctx, src, dst, len)
Definition: crypto.h:243
uint32_t len
Length.
Definition: ena.h:14

References assert(), cipher_algorithm::blocksize, cipher_decrypt, ctx, len, and src.