2
* Copyright (C) 2009 Michael Brown <mbrown@fensystems.co.uk>.
4
* This program is free software; you can redistribute it and/or
5
* modify it under the terms of the GNU General Public License as
6
* published by the Free Software Foundation; either version 2 of the
7
* License, or any later version.
9
* This program is distributed in the hope that it will be useful, but
10
* WITHOUT ANY WARRANTY; without even the implied warranty of
11
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12
* General Public License for more details.
14
* You should have received a copy of the GNU General Public License
15
* along with this program; if not, write to the Free Software
16
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
19
* You can also choose to distribute this program under the terms of
20
* the Unmodified Binary Distribution Licence (as given in the file
21
* COPYING.UBDL), provided that you have satisfied its requirements.
24
FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL );
27
#include <ipxe/crypto.h>
32
* Electronic codebook (ECB)
40
* @v src Data to encrypt
41
* @v dst Buffer for encrypted data
42
* @v len Length of data
43
* @v raw_cipher Underlying cipher algorithm
45
void ecb_encrypt ( void *ctx, const void *src, void *dst, size_t len,
46
struct cipher_algorithm *raw_cipher ) {
47
size_t blocksize = raw_cipher->blocksize;
49
assert ( ( len % blocksize ) == 0 );
52
cipher_encrypt ( raw_cipher, ctx, src, dst, blocksize );
63
* @v src Data to decrypt
64
* @v dst Buffer for decrypted data
65
* @v len Length of data
66
* @v raw_cipher Underlying cipher algorithm
68
void ecb_decrypt ( void *ctx, const void *src, void *dst, size_t len,
69
struct cipher_algorithm *raw_cipher ) {
70
size_t blocksize = raw_cipher->blocksize;
72
assert ( ( len % blocksize ) == 0 );
75
cipher_decrypt ( raw_cipher, ctx, src, dst, blocksize );