/*
* GCRYPT crypto backend implementation
*
- * Copyright (C) 2010 Red Hat, Inc. All rights reserved.
+ * Copyright (C) 2010-2011, Red Hat, Inc. All rights reserved.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
#include <string.h>
int hash_len;
};
-int crypt_backend_init(void)
+int crypt_backend_init(struct crypt_device *ctx __attribute__((unused)))
{
if (crypto_backend_initialised)
return 0;
return 0;
}
-int crypt_hash_restart(struct crypt_hash *ctx)
+static void crypt_hash_restart(struct crypt_hash *ctx)
{
gcry_md_reset(ctx->hd);
- return 0;
}
int crypt_hash_write(struct crypt_hash *ctx, const char *buffer, size_t length)
{
unsigned char *hash;
- if (length > ctx->hash_len)
+ if (length > (size_t)ctx->hash_len)
return -EINVAL;
hash = gcry_md_read(ctx->hd, ctx->hash_id);
return -EINVAL;
memcpy(buffer, hash, length);
+ crypt_hash_restart(ctx);
+
return 0;
}
return 0;
}
-int crypt_hmac_restart(struct crypt_hmac *ctx)
+static void crypt_hmac_restart(struct crypt_hmac *ctx)
{
gcry_md_reset(ctx->hd);
- return 0;
}
int crypt_hmac_write(struct crypt_hmac *ctx, const char *buffer, size_t length)
{
unsigned char *hash;
- if (length > ctx->hash_len)
+ if (length > (size_t)ctx->hash_len)
return -EINVAL;
hash = gcry_md_read(ctx->hd, ctx->hash_id);
return -EINVAL;
memcpy(buffer, hash, length);
+ crypt_hmac_restart(ctx);
+
return 0;
}