blowfish_cbc_crypt.c revision e81dd421aa6d230abe00ec58cd0bc87915d72406
/*
* Copyright 2006 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
#pragma ident "%Z%%M% %I% %E% SMI"
#include <sys/sysmacros.h>
#include "blowfish_cbc_crypt.h"
#include "blowfish_impl.h"
#ifndef _KERNEL
#include <strings.h>
#endif /* !_KERNEL */
/*
* Initialize by setting iov_or_mp to point to the current iovec or mp,
* and by setting current_offset to an offset within the current iovec or mp .
*/
static void
{
case CRYPTO_DATA_RAW:
break;
case CRYPTO_DATA_UIO: {
*current_offset = offset;
break;
}
case CRYPTO_DATA_MBLK: {
*current_offset = offset;
break;
}
} /* end switch */
}
/*
* Get pointers for where in the output to copy a block of encrypted or
* decrypted data. The iov_or_mp argument stores a pointer to the current
* iovec or mp, and offset stores an offset into the current iovec or mp.
*/
static void
{
case CRYPTO_DATA_RAW: {
offset = *current_offset;
/* one BLOWFISH block fits */
*out_data_2 = NULL;
}
break;
}
case CRYPTO_DATA_UIO: {
uint8_t *p;
offset = *current_offset;
*out_data_1 = p;
/* can fit one BLOWFISH block into this iov */
*out_data_2 = NULL;
} else {
/* one BLOWFISH block spans two iovecs */
return;
vec_idx++;
}
break;
}
case CRYPTO_DATA_MBLK: {
uint8_t *p;
offset = *current_offset;
*out_data_1 = p;
/* can fit one BLOWFISH block into this mblk */
*out_data_2 = NULL;
} else {
/* one BLOWFISH block spans two mblks */
return;
}
break;
}
} /* end switch */
}
/*
* Encrypt multiple blocks of data.
*/
int
{
/* EXPORT DELETE START */
void *iov_or_mp;
/* accumulate bytes here and return */
length);
return (0);
}
do {
/* Unprocessed data from last call. */
if (ctx->bc_remainder_len > 0) {
return (1);
} else {
}
/* don't write on the plaintext */
/* LINTED: pointer alignment */
/* LINTED: pointer alignment */
} else {
}
}
/*
* XOR the previous cipher block or IV with the
* current clear block. Check for alignment.
*/
/* LINTED: pointer alignment */
/* LINTED: pointer alignment */
/* LINTED: pointer alignment */
/* LINTED: pointer alignment */
} else {
}
}
blockp);
if (ctx->bc_remainder_len > 0) {
need);
}
} else {
&out_data_1_len, &out_data_2);
/* copy block to where it belongs */
if (out_data_2 != NULL) {
}
/* update offset */
}
/* Update pointer to next block of data to be processed. */
if (ctx->bc_remainder_len != 0) {
ctx->bc_remainder_len = 0;
} else {
}
/* Incomplete last block. */
goto out;
}
} while (remainder > 0);
out:
/* LINTED: pointer alignment */
/* LINTED: pointer alignment */
} else {
}
}
/* EXPORT DELETE END */
return (0);
}
int
{
/* EXPORT DELETE START */
void *iov_or_mp;
/* accumulate bytes here and return */
length);
return (0);
}
do {
/* Unprocessed data from last call. */
if (ctx->bc_remainder_len > 0) {
return (1);
} else {
}
/* Save current ciphertext block */
/* LINTED: pointer alignment */
ctx);
/* LINTED: pointer alignment */
/* LINTED: pointer alignment */
} else {
/* LINTED: pointer alignment */
}
}
} else {
blockp);
}
/*
* XOR the previous cipher block or IV with the
* currently decrypted block. Check for alignment.
*/
/* LINTED: pointer alignment */
/* LINTED: pointer alignment */
/* LINTED: pointer alignment */
} else {
}
/* LINTED: pointer alignment */
}
&out_data_1_len, &out_data_2);
/* copy temporary block to where it belongs */
if (out_data_2 != NULL) {
}
/* update offset */
} else if (ctx->bc_remainder_len > 0) {
/* copy temporary block to where it belongs */
}
/* Update pointer to next block of data to be processed. */
if (ctx->bc_remainder_len != 0) {
ctx->bc_remainder_len = 0;
} else {
}
/* Incomplete last block. */
return (0);
}
} while (remainder > 0);
/* EXPORT DELETE END */
return (0);
}