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.
void ecb_decrypt (void *ctx, const void *src, void *dst, size_t len, struct cipher_algorithm *raw_cipher)
 Decrypt data.

Detailed Description

Electronic codebook (ECB)

Definition in file ecb.c.


Function Documentation

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.

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

Definition at line 45 of file ecb.c.

References assert, cipher_algorithm::blocksize, and cipher_encrypt.

                                                         {
        size_t blocksize = raw_cipher->blocksize;

        assert ( ( len % blocksize ) == 0 );

        while ( len ) {
                cipher_encrypt ( raw_cipher, ctx, src, dst, blocksize );
                dst += blocksize;
                src += blocksize;
                len -= blocksize;
        }
}
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.

References assert, cipher_algorithm::blocksize, and cipher_decrypt.

                                                         {
        size_t blocksize = raw_cipher->blocksize;

        assert ( ( len % blocksize ) == 0 );

        while ( len ) {
                cipher_decrypt ( raw_cipher, ctx, src, dst, blocksize );
                dst += blocksize;
                src += blocksize;
                len -= blocksize;
        }
}