summaryrefslogtreecommitdiff
path: root/gs/base/saes.c
diff options
context:
space:
mode:
Diffstat (limited to 'gs/base/saes.c')
-rw-r--r--gs/base/saes.c42
1 files changed, 21 insertions, 21 deletions
diff --git a/gs/base/saes.c b/gs/base/saes.c
index a08fc93a1..b7c2cc282 100644
--- a/gs/base/saes.c
+++ b/gs/base/saes.c
@@ -24,19 +24,19 @@
/* stream implementation */
private_st_aes_state(); /* creates a gc object for our state,
- defined in saes.h */
+ defined in saes.h */
/* Store a key in our crypt context */
int
s_aes_set_key(stream_aes_state * state, const unsigned char *key,
- int keylength)
+ int keylength)
{
int code = 0;
if ( (keylength < 1) || (keylength > SAES_MAX_KEYLENGTH) )
- return_error(gs_error_rangecheck);
+ return_error(gs_error_rangecheck);
if (key == NULL)
- return_error(gs_error_invalidaccess);
+ return_error(gs_error_invalidaccess);
/* we can't set the key here because the interpreter's
filter implementation wants to duplicate our state
@@ -90,7 +90,7 @@ s_aes_release(stream_state *ss)
*/
static int
s_aes_process(stream_state * ss, stream_cursor_read * pr,
- stream_cursor_write * pw, bool last)
+ stream_cursor_write * pw, bool last)
{
stream_aes_state *const state = (stream_aes_state *) ss;
const unsigned char *limit;
@@ -101,11 +101,11 @@ s_aes_process(stream_state * ss, stream_cursor_read * pr,
/* figure out if we're going to run out of space */
if (in_size > out_size) {
- limit = pr->ptr + out_size;
- status = 1; /* need more output space */
+ limit = pr->ptr + out_size;
+ status = 1; /* need more output space */
} else {
- limit = pr->limit;
- status = last ? EOFC : 0; /* need more input */
+ limit = pr->limit;
+ status = last ? EOFC : 0; /* need more input */
}
/* set up state and context */
@@ -114,30 +114,30 @@ s_aes_process(stream_state * ss, stream_cursor_read * pr,
contains internal pointers, so we need to store it separately
in immovable memory like any opaque structure. */
state->ctx = (aes_context *)gs_alloc_bytes_immovable(state->memory,
- sizeof(aes_context), "aes context structure");
+ sizeof(aes_context), "aes context structure");
if (state->ctx == NULL) {
- gs_throw(gs_error_VMerror, "could not allocate aes context");
- return ERRC;
+ gs_throw(gs_error_VMerror, "could not allocate aes context");
+ return ERRC;
}
if (state->keylength < 1 || state->keylength > SAES_MAX_KEYLENGTH) {
- gs_throw1(gs_error_rangecheck, "invalid aes key length (%d bytes)",
- state->keylength);
- return ERRC;
+ gs_throw1(gs_error_rangecheck, "invalid aes key length (%d bytes)",
+ state->keylength);
+ return ERRC;
}
aes_setkey_dec(state->ctx, state->key, state->keylength * 8);
}
if (!state->initialized) {
- /* read the initialization vector from the first 16 bytes */
- if (in_size < 16) return 0; /* get more data */
- memcpy(state->iv, pr->ptr + 1, 16);
- state->initialized = 1;
- pr->ptr += 16;
+ /* read the initialization vector from the first 16 bytes */
+ if (in_size < 16) return 0; /* get more data */
+ memcpy(state->iv, pr->ptr + 1, 16);
+ state->initialized = 1;
+ pr->ptr += 16;
}
/* decrypt available blocks */
while (pr->ptr + 16 <= limit) {
aes_crypt_cbc(state->ctx, AES_DECRYPT, 16, state->iv,
- pr->ptr + 1, temp);
+ pr->ptr + 1, temp);
pr->ptr += 16;
if (last && pr->ptr == pr->limit) {
/* we're on the last block; unpad if necessary */