fips_sha1_util.c revision 32e0ab73531b6e6e8957e9ecdbbd42603865f2d0
/*
* CDDL HEADER START
*
* The contents of this file are subject to the terms of the
* Common Development and Distribution License (the "License").
* You may not use this file except in compliance with the License.
*
* You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
* See the License for the specific language governing permissions
* and limitations under the License.
*
* When distributing Covered Code, include this CDDL HEADER in each
* file and include the License file at usr/src/OPENSOLARIS.LICENSE.
* If applicable, add the following below this CDDL HEADER, with the
* fields enclosed by brackets "[]" replaced with your own identifying
* information: Portions Copyright [yyyy] [name of copyright owner]
*
* CDDL HEADER END
*/
/*
*/
#ifndef _KERNEL
#include <stdlib.h>
#include <string.h>
#include <strings.h>
#include <stdio.h>
#include <security/cryptoki.h>
#include <cryptoutil.h>
#include "softMAC.h"
#endif
#include <sha1/sha1_impl.h>
#define _SHA1_FIPS_POST
#include <fips/fips_test_vectors.h>
/*
* fips_sha1_build_context()
*
* Description:
* This function allocates and initializes SHA1 context
* context.
*/
SHA1_CTX *
fips_sha1_build_context(void)
{
#ifndef _KERNEL
#else
#endif
return (NULL);
return (sha1_context);
}
/*
* fips_sha1_hash()
*
* Arguments:
* sha1_context: pointer to SHA1 context
* in: pointer to the input data to be hashed
* inlen: length of the input data
* out: pointer to the output data after hashing
*
* Description:
* This function calls the low-level SHA1 routines for hashing.
*
*/
int
{
int rv;
#ifdef __sparcv9
#else /* !__sparcv9 */
#endif /* __sparcv9 */
} else
if (sha1_context)
#ifdef _KERNEL
#else
#endif
return (rv);
}
#ifndef _KERNEL
unsigned int secret_key_length)
{
return (NULL);
}
return (hmac_ctx);
}
fips_hmac_sha1_hash(unsigned char *hmac_computed,
unsigned int secret_key_length,
unsigned int message_length)
{
return (CKR_HOST_MEMORY);
}
return (CKR_OK);
}
#else /* _KERNEL */
/*
* Initialize a SHA1-HMAC context.
*/
void
{
uint_t i;
/* XOR key with ipad (0x36) and opad (0x5c) */
for (i = 0; i < SHA1_HMAC_INTS_PER_BLOCK; i++) {
ipad[i] ^= 0x36363636;
opad[i] ^= 0x5c5c5c5c;
}
/* perform SHA1 on ipad */
/* perform SHA1 on opad */
}
unsigned int secret_key_length)
{
/*
* Allocate and initialize SHA1 context.
*/
KM_SLEEP);
if (sha1_hmac_ctx_tmpl == NULL)
return (NULL);
/*
* initialize ctx->hc_icontext and ctx->hc_ocontext
*/
return (sha1_hmac_ctx_tmpl);
}
void
{
/* do a SHA1 update of the inner context using the specified data */
/*
* Do a SHA1 final on the inner context.
*/
/*
* Do an SHA1 update on the outer context, feeding the inner
* digest as data.
*/
/*
* Do a SHA1 final on the outer context, storing the computed
* digest in the caller's buffer.
*/
}
#endif
/*
* SHA1 Power-On SelfTest(s).
*/
int
fips_sha1_post(void)
{
= sizeof (HMAC_known_secret_key);
/* SHA-1 variables. */
#ifdef _KERNEL
#endif
int rv;
/* SHA-1 Known Answer Hashing Test. */
if (sha1_context == NULL)
return (CKR_HOST_MEMORY);
SHA1_DIGEST_LENGTH) != 0))
return (CKR_DEVICE_ERROR);
#ifdef _KERNEL
/* SHA-1 HMAC Known Answer Hashing Test */
if (sha1_hmac_ctx == NULL)
return (CKR_HOST_MEMORY);
sizeof (hmac_sha1_known_hash_message), hmac_computed);
#else
sizeof (hmac_sha1_known_hash_message));
#endif
#ifdef _KERNEL
sizeof (known_SHA1_hmac)) != 0)
return (CKR_DEVICE_ERROR);
#else
sizeof (known_SHA1_hmac)) != 0))
return (CKR_DEVICE_ERROR);
#endif
return (rv);
}