aes_provider.c revision 7c478bd95313f5f23a4c958a745db2134aa03244
/*
* Copyright 2004 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
#pragma ident "%Z%%M% %I% %E% SMI"
#include <k5-int.h>
#include <enc_provider.h>
#define BLOCK_SIZE 16
static void
{
*blocksize = 16;
}
static void
{
}
static void
{
}
/*ARGSUSED*/
{
krb5_error_code ret = 0;
#ifdef _KERNEL
int result = 0;
#else
#endif /* _KERNEL */
else
#ifndef _KERNEL
goto cleanup;
goto cleanup;
"krb5int_aes_encrypt: rv = 0x%x", rv);
goto cleanup;
}
#endif /* !_KERNEL */
if (nblocks == 1) {
#ifndef _KERNEL
/* XXX Used for DK function. */
(CK_ULONG_PTR)&outlen);
#else
#endif /* _KERNEL */
} else {
int nleft;
#ifdef _KERNEL
if (result != CRYPTO_SUCCESS)
goto cleanup;
#else
#endif /* _KERNEL */
#ifdef _KERNEL
if (result != CRYPTO_SUCCESS) {
"crypto_encrypt_update: error: rv = 0x%08x",
result);
goto cleanup;
}
#else
(CK_ULONG_PTR)&outlen);
goto cleanup;
outlen);
#endif
}
/* Do final CTS step for last two blocks (the second of which
may or may not be incomplete). */
#ifdef _KERNEL
if (result != CRYPTO_SUCCESS) {
"crypto_encrypt_update: error: rv = 0x%08x", result);
goto cleanup;
}
#else
(CK_ULONG_PTR)&outlen);
goto cleanup;
#endif /* _KERNEL */
/*
* This effectively adds 0's as pad bytes if the last
* block is not exactly BLOCK_SIZE.
*/
#ifdef _KERNEL
if (result != CRYPTO_SUCCESS) {
"crypto_encrypt_update: error: rv = 0x%08x", result);
goto cleanup;
}
#else
(CK_ULONG_PTR)&outlen);
goto cleanup;
#endif /* _KERNEL */
tmp2, BLOCK_SIZE);
}
#ifdef _KERNEL
#else
/* Close the crypto session, ignore the output */
goto cleanup;
#endif /* _KERNEL */
}
#ifdef _KERNEL
#else
#endif /* _KERNEL */
if (ret)
return (ret);
}
/*ARGSUSED*/
{
krb5_error_code ret = 0;
#ifdef _KERNEL
int result = 0;
#else
#endif /* _KERNEL */
else
#ifndef _KERNEL
goto cleanup;
goto cleanup;
}
"krb5int_aes_decrypt: rv = 0x%x", rv);
goto cleanup;
}
#endif
if (nblocks == 1) {
return (KRB5_CRYPTO_INTERNAL);
#ifndef _KERNEL
#else
#endif /* _KERNEL */
} else {
#ifdef _KERNEL
if (result != CRYPTO_SUCCESS)
goto cleanup;
#endif /* _KERNEL */
#ifdef _KERNEL
blockno);
if (result != CRYPTO_SUCCESS) {
"crypto_decrypt_update: error: rv = 0x%08x",
result);
goto cleanup;
}
#else
(CK_ULONG_PTR)&outlen);
goto cleanup;
#endif /* _KERNEL */
tmp2, BLOCK_SIZE);
}
/* Do last two blocks, the second of which (next-to-last block
of plaintext) may be incomplete. */
#ifdef _KERNEL
if (result != CRYPTO_SUCCESS) {
"crypto_decrypt_update: error: rv = 0x%08x",
result);
goto cleanup;
}
#else
(CK_ULONG_PTR)&outlen);
goto cleanup;
#endif /* _KERNEL */
/* Set tmp3 to last ciphertext block, padded. */
/* Set tmp2 to last (possibly partial) plaintext block, and save it. */
/*
* Maybe keep the trailing part, and copy in the
* last ciphertext block.
*/
/*
* Decrypt, to get next to last plaintext block xor
* previous ciphertext.
*/
#ifdef _KERNEL
if (result != CRYPTO_SUCCESS) {
"crypto_decrypt_update: error: rv = 0x%08x",
result);
goto cleanup;
}
#else
(CK_ULONG_PTR)&outlen);
goto cleanup;
#endif /* _KERNEL */
tmp3, BLOCK_SIZE);
if (ivec)
#ifdef _KERNEL
#else
goto cleanup;
#endif /* _KERNEL */
}
#ifdef _KERNEL
#else
#endif /* _KERNEL */
if (ret)
return (ret);
}
static krb5_error_code
{
krb5_error_code ret = 0;
return(KRB5_BAD_KEYSIZE);
return(KRB5_CRYPTO_INTERNAL);
#ifdef _KERNEL
#else
#endif /* _KERNEL */
return (ret);
}
/*ARGSUSED*/
static krb5_error_code
{
if (!state)
return (0);
return ENOMEM;
return (0);
}
const struct krb5_enc_provider krb5int_enc_aes128 = {
};
const struct krb5_enc_provider krb5int_enc_aes256 = {
};