summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNikos Mavrogiannopoulos <nmav@redhat.com>2018-02-22 11:43:53 +0100
committerNikos Mavrogiannopoulos <nmav@redhat.com>2018-02-22 13:57:49 +0100
commit005e5187871ebf03ac5f6a212bc39f14fce534b9 (patch)
tree6cd1dd28b14e20086d48a4c020f2ff8a9bfc3d36
parentee031d68d5c611c8c9a40ea3917396f92a1059f9 (diff)
downloadgnutls-tmp-update-nettle-apis.tar.gz
drbg-aes: use the new nettle APIs for AEStmp-update-nettle-apis
Signed-off-by: Nikos Mavrogiannopoulos <nmav@redhat.com>
-rw-r--r--lib/nettle/int/drbg-aes.c22
-rw-r--r--lib/nettle/int/drbg-aes.h4
2 files changed, 13 insertions, 13 deletions
diff --git a/lib/nettle/int/drbg-aes.c b/lib/nettle/int/drbg-aes.c
index f8b693bcd1..625ae80ab9 100644
--- a/lib/nettle/int/drbg-aes.c
+++ b/lib/nettle/int/drbg-aes.c
@@ -1,6 +1,6 @@
/* drbg-aes.c */
-/* Copyright (C) 2013, 2014 Red Hat
+/* Copyright (C) 2013-2018 Red Hat
*
* This file is part of GnuTLS.
*
@@ -15,9 +15,7 @@
* License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
- * along with the nettle library; see the file COPYING.LIB. If not, write to
- * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
- * MA 02111-1301, USA.
+ * along with this program. If not, see <http://www.gnu.org/licenses/>
*/
#include <config.h>
@@ -28,18 +26,20 @@
#include <string.h>
#include <stdio.h>
#include <fips.h>
+#include <assert.h>
int
drbg_aes_init(struct drbg_aes_ctx *ctx,
unsigned entropy_size, const uint8_t * entropy,
unsigned pstring_size, const uint8_t * pstring)
{
- uint8_t tmp[DRBG_AES_KEY_SIZE];
+ uint8_t tmp[AES256_KEY_SIZE];
+ assert(AES256_KEY_SIZE == DRBG_AES_KEY_SIZE);
memset(ctx, 0, sizeof(*ctx));
memset(tmp, 0, sizeof(tmp));
- aes_set_encrypt_key(&ctx->key, DRBG_AES_KEY_SIZE, tmp);
+ aes256_set_encrypt_key(&ctx->key, tmp);
return drbg_aes_reseed(ctx, entropy_size, entropy,
pstring_size, pstring);
@@ -56,14 +56,14 @@ drbg_aes_update(struct drbg_aes_ctx *ctx,
while (len < DRBG_AES_SEED_SIZE) {
INCREMENT(sizeof(ctx->v), ctx->v);
- aes_encrypt(&ctx->key, AES_BLOCK_SIZE, t, ctx->v);
+ aes256_encrypt(&ctx->key, AES_BLOCK_SIZE, t, ctx->v);
t += AES_BLOCK_SIZE;
len += AES_BLOCK_SIZE;
}
memxor(tmp, pdata, DRBG_AES_SEED_SIZE);
- aes_set_encrypt_key(&ctx->key, DRBG_AES_KEY_SIZE, tmp);
+ aes256_set_encrypt_key(&ctx->key, tmp);
memcpy(ctx->v, &tmp[DRBG_AES_KEY_SIZE], AES_BLOCK_SIZE);
@@ -148,7 +148,7 @@ int drbg_aes_generate(struct drbg_aes_ctx *ctx, unsigned length, uint8_t * dst,
*/
if (ctx->prev_block_present == 0) {
INCREMENT(sizeof(ctx->v), ctx->v);
- aes_encrypt(&ctx->key, AES_BLOCK_SIZE, ctx->prev_block, ctx->v);
+ aes256_encrypt(&ctx->key, AES_BLOCK_SIZE, ctx->prev_block, ctx->v);
ctx->prev_block_present = 1;
}
@@ -158,7 +158,7 @@ int drbg_aes_generate(struct drbg_aes_ctx *ctx, unsigned length, uint8_t * dst,
left -= AES_BLOCK_SIZE, dst += AES_BLOCK_SIZE) {
INCREMENT(sizeof(ctx->v), ctx->v);
- aes_encrypt(&ctx->key, AES_BLOCK_SIZE, dst, ctx->v);
+ aes256_encrypt(&ctx->key, AES_BLOCK_SIZE, dst, ctx->v);
/* if detected loop */
if (memcmp(dst, ctx->prev_block, AES_BLOCK_SIZE) == 0) {
@@ -172,7 +172,7 @@ int drbg_aes_generate(struct drbg_aes_ctx *ctx, unsigned length, uint8_t * dst,
if (left > 0) { /* partial fill */
INCREMENT(sizeof(ctx->v), ctx->v);
- aes_encrypt(&ctx->key, AES_BLOCK_SIZE, tmp, ctx->v);
+ aes256_encrypt(&ctx->key, AES_BLOCK_SIZE, tmp, ctx->v);
/* if detected loop */
if (memcmp(tmp, ctx->prev_block, AES_BLOCK_SIZE) == 0) {
diff --git a/lib/nettle/int/drbg-aes.h b/lib/nettle/int/drbg-aes.h
index 72608defe8..1d421a69e9 100644
--- a/lib/nettle/int/drbg-aes.h
+++ b/lib/nettle/int/drbg-aes.h
@@ -38,7 +38,7 @@
; \
} while (0)
-#define DRBG_AES_KEY_SIZE 32
+#define DRBG_AES_KEY_SIZE AES256_KEY_SIZE
#define DRBG_AES_SEED_SIZE (AES_BLOCK_SIZE+DRBG_AES_KEY_SIZE)
/* This is the CTR-AES-256-based random-number generator from SP800-90A.
@@ -46,7 +46,7 @@
struct drbg_aes_ctx {
unsigned seeded;
/* The current key */
- struct aes_ctx key;
+ struct aes256_ctx key;
uint8_t v[AES_BLOCK_SIZE];