aboutsummaryrefslogtreecommitdiffstats
path: root/gpxe/src/crypto/cipher.c
blob: 9c392009a7085721dffe4e5afd9eaa0f0de44a7c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
#include <stdint.h>
#include <errno.h>
#include <gpxe/crypto.h>

int cipher_encrypt ( struct crypto_algorithm *crypto,
		     void *ctx, const void *src, void *dst,
		     size_t len ) {
	if ( ( len & ( crypto->blocksize - 1 ) ) ) {
		return -EINVAL;
	}
	crypto->encode ( ctx, src, dst, len );
	return 0;
}

int cipher_decrypt ( struct crypto_algorithm *crypto,
		     void *ctx, const void *src, void *dst,
		     size_t len ) {
	if ( ( len & ( crypto->blocksize - 1 ) ) ) {
		return -EINVAL;
	}
	crypto->decode ( ctx, src, dst, len );
	return 0;
}