From 38d62bec91558562f738dd4730d7a9dbb3fabf7d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Joachim=20Stro=CC=88mbergson?= Date: Wed, 1 Apr 2015 16:28:03 +0200 Subject: Refactor: Moved all address defines for cryptech cores into a common header file. --- eim/sw/hash_eim.c | 84 ++++--------------------------------------------------- 1 file changed, 5 insertions(+), 79 deletions(-) (limited to 'eim/sw/hash_eim.c') diff --git a/eim/sw/hash_eim.c b/eim/sw/hash_eim.c index 281914c..8ea761b 100644 --- a/eim/sw/hash_eim.c +++ b/eim/sw/hash_eim.c @@ -1,13 +1,13 @@ -/* +/* * hash.c * ------ * This program uses the coretest_hashes subsystem to produce a * cryptographic hash of a file or input stream. It is a generalization * of the hash_tester.c test program. - * + * * Authors: Joachim Strömbergson, Paul Selkirk * Copyright (c) 2014-2015, NORDUnet A/S All rights reserved. - * + * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are * met: @@ -51,8 +51,9 @@ #include #include "tc_eim.h" +#include "cryptech_memory_map.h" -char *usage = +char *usage = "Usage: %s [-d] [-v] [-q] [algorithm [file]]\n" "algorithms: sha-1, sha-256, sha-512/224, sha-512/256, sha-384, sha-512\n"; @@ -60,81 +61,6 @@ int debug = 0; int quiet = 0; int verbose = 0; -/* memory segments for core families */ -#define SEGMENT_OFFSET_GLOBALS EIM_BASE_ADDR + 0x000000 -#define SEGMENT_OFFSET_HASHES EIM_BASE_ADDR + 0x010000 -#define SEGMENT_OFFSET_RNGS EIM_BASE_ADDR + 0x020000 -#define SEGMENT_OFFSET_CIPHERS EIM_BASE_ADDR + 0x030000 - -#define CORE_SIZE (0x100 << 2) - -/* addresses and codes common to all cores */ -#define ADDR_NAME0 (0x0 << 2) -#define ADDR_NAME1 (0x1 << 2) -#define ADDR_VERSION (0x2 << 2) - -/* At segment 0, we have board-level register and communication channel registers */ -#define BOARD_ADDR_BASE SEGMENT_OFFSET_GLOBALS + (0x00 * CORE_SIZE) -#define BOARD_ADDR_NAME0 BOARD_ADDR_BASE + ADDR_NAME0 -#define BOARD_ADDR_NAME1 BOARD_ADDR_BASE + ADDR_NAME1 -#define BOARD_ADDR_VERSION BOARD_ADDR_BASE + ADDR_VERSION -#define BOARD_ADDR_DUMMY BOARD_ADDR_BASE + (0xFF << 2) - -#define COMM_ADDR_BASE SEGMENT_OFFSET_GLOBALS + (0x01 * CORE_SIZE) -#define COMM_ADDR_NAME0 COMM_ADDR_BASE + ADDR_NAME0 -#define COMM_ADDR_NAME1 COMM_ADDR_BASE + ADDR_NAME1 -#define COMM_ADDR_VERSION COMM_ADDR_BASE + ADDR_VERSION - -/* addresses and codes common to all hash cores */ -#define ADDR_CTRL (0x8 << 2) -#define CTRL_INIT_CMD 1 -#define CTRL_NEXT_CMD 2 -#define ADDR_STATUS (9 << 2) -#define STATUS_READY_BIT 1 -#define STATUS_VALID_BIT 2 -#define ADDR_BLOCK (0x10 << 2) -#define ADDR_DIGEST (0x20 << 2) - -/* addresses and codes for the specific hash cores */ -#define SHA1_ADDR_BASE SEGMENT_OFFSET_HASHES + (0*CORE_SIZE) -#define SHA1_ADDR_NAME0 SHA1_ADDR_BASE + ADDR_NAME0 -#define SHA1_ADDR_NAME1 SHA1_ADDR_BASE + ADDR_NAME1 -#define SHA1_ADDR_VERSION SHA1_ADDR_BASE + ADDR_VERSION -#define SHA1_ADDR_CTRL SHA1_ADDR_BASE + ADDR_CTRL -#define SHA1_ADDR_STATUS SHA1_ADDR_BASE + ADDR_STATUS -#define SHA1_ADDR_BLOCK SHA1_ADDR_BASE + ADDR_BLOCK -#define SHA1_ADDR_DIGEST SHA1_ADDR_BASE + ADDR_DIGEST -#define SHA1_BLOCK_LEN 512 / 8 -#define SHA1_DIGEST_LEN 160 / 8 - -#define SHA256_ADDR_BASE SEGMENT_OFFSET_HASHES + (1*CORE_SIZE) -#define SHA256_ADDR_NAME0 SHA256_ADDR_BASE + ADDR_NAME0 -#define SHA256_ADDR_NAME1 SHA256_ADDR_BASE + ADDR_NAME1 -#define SHA256_ADDR_VERSION SHA256_ADDR_BASE + ADDR_VERSION -#define SHA256_ADDR_CTRL SHA256_ADDR_BASE + ADDR_CTRL -#define SHA256_ADDR_STATUS SHA256_ADDR_BASE + ADDR_STATUS -#define SHA256_ADDR_BLOCK SHA256_ADDR_BASE + ADDR_BLOCK -#define SHA256_ADDR_DIGEST SHA256_ADDR_BASE + ADDR_DIGEST -#define SHA256_BLOCK_LEN 512 / 8 -#define SHA256_DIGEST_LEN 256 / 8 - -#define SHA512_ADDR_BASE SEGMENT_OFFSET_HASHES + (2*CORE_SIZE) -#define SHA512_ADDR_NAME0 SHA512_ADDR_BASE + ADDR_NAME0 -#define SHA512_ADDR_NAME1 SHA512_ADDR_BASE + ADDR_NAME1 -#define SHA512_ADDR_VERSION SHA512_ADDR_BASE + ADDR_VERSION -#define SHA512_ADDR_CTRL SHA512_ADDR_BASE + ADDR_CTRL -#define SHA512_ADDR_STATUS SHA512_ADDR_BASE + ADDR_STATUS -#define SHA512_ADDR_BLOCK SHA512_ADDR_BASE + ADDR_BLOCK -#define SHA512_ADDR_DIGEST SHA512_ADDR_BASE + (0x40 << 2) -#define SHA512_BLOCK_LEN 1024 / 8 -#define SHA512_224_DIGEST_LEN 224 / 8 -#define SHA512_256_DIGEST_LEN 256 / 8 -#define SHA384_DIGEST_LEN 384 / 8 -#define SHA512_DIGEST_LEN 512 / 8 -#define MODE_SHA_512_224 0 << 2 -#define MODE_SHA_512_256 1 << 2 -#define MODE_SHA_384 2 << 2 -#define MODE_SHA_512 3 << 2 /* ---------------- algorithm lookup code ---------------- */ -- cgit v1.2.3