47e946e784719ae402ace34695f67b0e6e76ae5cWyllys Ingersoll * The Initial Developer of the Original Code is International
47e946e784719ae402ace34695f67b0e6e76ae5cWyllys Ingersoll * Business Machines Corporation. Portions created by IBM
47e946e784719ae402ace34695f67b0e6e76ae5cWyllys Ingersoll * Corporation are Copyright (C) 2005 International Business
47e946e784719ae402ace34695f67b0e6e76ae5cWyllys Ingersoll * Machines Corporation. All Rights Reserved.
47e946e784719ae402ace34695f67b0e6e76ae5cWyllys Ingersoll * This program is free software; you can redistribute it and/or modify
47e946e784719ae402ace34695f67b0e6e76ae5cWyllys Ingersoll * it under the terms of the Common Public License as published by
47e946e784719ae402ace34695f67b0e6e76ae5cWyllys Ingersoll * IBM Corporation; either version 1 of the License, or (at your option)
47e946e784719ae402ace34695f67b0e6e76ae5cWyllys Ingersoll * any later version.
47e946e784719ae402ace34695f67b0e6e76ae5cWyllys Ingersoll * This program is distributed in the hope that it will be useful,
47e946e784719ae402ace34695f67b0e6e76ae5cWyllys Ingersoll * but WITHOUT ANY WARRANTY; without even the implied warranty of
47e946e784719ae402ace34695f67b0e6e76ae5cWyllys Ingersoll * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
47e946e784719ae402ace34695f67b0e6e76ae5cWyllys Ingersoll * Common Public License for more details.
47e946e784719ae402ace34695f67b0e6e76ae5cWyllys Ingersoll * You should have received a copy of the Common Public License
47e946e784719ae402ace34695f67b0e6e76ae5cWyllys Ingersoll * along with this program; if not, a copy can be viewed at
47e946e784719ae402ace34695f67b0e6e76ae5cWyllys Ingersoll * http://www.opensource.org/licenses/cpl1.0.php.
47e946e784719ae402ace34695f67b0e6e76ae5cWyllys Ingersoll/* (C) COPYRIGHT International Business Machines Corp. 2001, 2002, 2005 */
47e946e784719ae402ace34695f67b0e6e76ae5cWyllys Ingersoll * Copyright 2009 Sun Microsystems, Inc. All rights reserved.
47e946e784719ae402ace34695f67b0e6e76ae5cWyllys Ingersoll * Use is subject to license terms.
47e946e784719ae402ace34695f67b0e6e76ae5cWyllys Ingersoll SHA1Update(ctx->context.sha1ctx, in_data, in_data_len);
47e946e784719ae402ace34695f67b0e6e76ae5cWyllys Ingersoll if (ctx->mech.mechanism == CKM_SHA_1_HMAC_GENERAL) {
47e946e784719ae402ace34695f67b0e6e76ae5cWyllys Ingersoll hmac_len = *(CK_ULONG *)ctx->mech.pParameter;
47e946e784719ae402ace34695f67b0e6e76ae5cWyllys Ingersoll (void) memset(&digest_ctx, 0x0, sizeof (DIGEST_CONTEXT));
47e946e784719ae402ace34695f67b0e6e76ae5cWyllys Ingersoll rc = object_mgr_find_in_map1(sess->hContext, ctx->key, &key_obj);
47e946e784719ae402ace34695f67b0e6e76ae5cWyllys Ingersoll rc = template_attribute_find(key_obj->template, CKA_VALUE, &attr);
47e946e784719ae402ace34695f67b0e6e76ae5cWyllys Ingersoll rc = digest_mgr_init(sess, &digest_ctx, &digest_mech);
47e946e784719ae402ace34695f67b0e6e76ae5cWyllys Ingersoll rc = digest_mgr_digest(sess, FALSE, &digest_ctx,
47e946e784719ae402ace34695f67b0e6e76ae5cWyllys Ingersoll attr->pValue, attr->ulValueLen, hash, &hash_len);
47e946e784719ae402ace34695f67b0e6e76ae5cWyllys Ingersoll (void) memset(&digest_ctx, 0x0, sizeof (DIGEST_CONTEXT));
47e946e784719ae402ace34695f67b0e6e76ae5cWyllys Ingersoll for (i = 0; i < hash_len; i++) {
47e946e784719ae402ace34695f67b0e6e76ae5cWyllys Ingersoll (void) memset(&k_ipad[i], 0x36, SHA1_BLOCK_SIZE - i);
47e946e784719ae402ace34695f67b0e6e76ae5cWyllys Ingersoll (void) memset(&k_opad[i], 0x5C, SHA1_BLOCK_SIZE - i);
47e946e784719ae402ace34695f67b0e6e76ae5cWyllys Ingersoll for (i = 0; i < key_bytes; i++) {
47e946e784719ae402ace34695f67b0e6e76ae5cWyllys Ingersoll (void) memset(&k_ipad[i], 0x36, SHA1_BLOCK_SIZE - key_bytes);
47e946e784719ae402ace34695f67b0e6e76ae5cWyllys Ingersoll (void) memset(&k_opad[i], 0x5C, SHA1_BLOCK_SIZE - key_bytes);
47e946e784719ae402ace34695f67b0e6e76ae5cWyllys Ingersoll rc = digest_mgr_digest_update(sess, &digest_ctx,
47e946e784719ae402ace34695f67b0e6e76ae5cWyllys Ingersoll rc = digest_mgr_digest_update(sess, &digest_ctx, in_data, in_data_len);
47e946e784719ae402ace34695f67b0e6e76ae5cWyllys Ingersoll rc = digest_mgr_digest_final(sess, &digest_ctx, hash, &hash_len);
47e946e784719ae402ace34695f67b0e6e76ae5cWyllys Ingersoll (void) memset(&digest_ctx, 0x0, sizeof (DIGEST_CONTEXT));
47e946e784719ae402ace34695f67b0e6e76ae5cWyllys Ingersoll rc = digest_mgr_init(sess, &digest_ctx, &digest_mech);
47e946e784719ae402ace34695f67b0e6e76ae5cWyllys Ingersoll rc = digest_mgr_digest_update(sess, &digest_ctx,
47e946e784719ae402ace34695f67b0e6e76ae5cWyllys Ingersoll rc = digest_mgr_digest_update(sess, &digest_ctx, hash, hash_len);
47e946e784719ae402ace34695f67b0e6e76ae5cWyllys Ingersoll rc = digest_mgr_digest_final(sess, &digest_ctx, hash, &hash_len);
47e946e784719ae402ace34695f67b0e6e76ae5cWyllys Ingersoll if (! sess || ! ctx || ! in_data || ! signature) {
47e946e784719ae402ace34695f67b0e6e76ae5cWyllys Ingersoll if (ctx->mech.mechanism == CKM_SHA_1_HMAC_GENERAL)
47e946e784719ae402ace34695f67b0e6e76ae5cWyllys Ingersoll hmac_len = *(CK_ULONG *)ctx->mech.pParameter;
47e946e784719ae402ace34695f67b0e6e76ae5cWyllys Ingersoll (void) memset(&hmac_ctx, 0, sizeof (SIGN_VERIFY_CONTEXT));
47e946e784719ae402ace34695f67b0e6e76ae5cWyllys Ingersoll rc = sign_mgr_init(sess, &hmac_ctx, &ctx->mech, FALSE, ctx->key);
47e946e784719ae402ace34695f67b0e6e76ae5cWyllys Ingersoll if ((len != hmac_len) || (len != sig_len)) {