summaryrefslogtreecommitdiffstats
path: root/src/crypto/cipher.c
blob: f83a6d0ffcb7a182dff1746b2d8aa9de1dced6d6 (plain) (blame)
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 cipher_algorithm *cipher,
		     void *ctx, const void *src, void *dst,
		     size_t len ) {
	if ( ( len & ( cipher->blocksize - 1 ) ) ) {
		return -EINVAL;
	}
	cipher->encrypt ( ctx, src, dst, len );
	return 0;
}

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