summaryrefslogtreecommitdiff
path: root/cesar/cp2
diff options
context:
space:
mode:
authorlaranjeiro2008-06-17 16:01:23 +0000
committerlaranjeiro2008-06-17 16:01:23 +0000
commit510a5ae408ee8d2d0ca49596c00ed8ce00e46cfa (patch)
treec3bad9d475d8bebe25d31afc685a6aa3c43a99d1 /cesar/cp2
parent7398c269d7b995c926794024bec70e6a742590ad (diff)
cp2/secu: Removed the merge errors.
git-svn-id: svn+ssh://pessac/svn/cesar/trunk@2363 017c9cb6-072f-447c-8318-d5b54f68fe89
Diffstat (limited to 'cesar/cp2')
-rw-r--r--cesar/cp2/secu/inc/sha256.h42
-rw-r--r--cesar/cp2/secu/sha256.h8
-rw-r--r--cesar/cp2/secu/src/sha256.c152
-rw-r--r--cesar/cp2/secu/test/src/test-sha2.c16
4 files changed, 0 insertions, 218 deletions
diff --git a/cesar/cp2/secu/inc/sha256.h b/cesar/cp2/secu/inc/sha256.h
index d9350fc0dd..cf883a2eb2 100644
--- a/cesar/cp2/secu/inc/sha256.h
+++ b/cesar/cp2/secu/inc/sha256.h
@@ -1,44 +1,3 @@
-<<<<<<< HEAD:cp2/secu/inc/sha256.h
-#ifndef cp2_secu_inc_sha256_h
-#define cp2_secu_inc_sha256_h
-/* Cesar project {{{
- *
- * Copyright (C) 2008 Spidcom
- *
- * <<<Licence>>>
- *
- * }}} */
-/**
- * \file cp2/secu/inc/sha256.h
- * \brief SHA 256 Private functions.
- * \ingroup cp2_secu
- */
-
-struct sha2_t
-{
- /*!< intermediate digest state */
- u32 state[8];
-};
-typedef struct sha2_t sha2_t;
-
-/** Initialise the SHA context.
- *
- * \param ctx the module context.
- */
-void
-cp_secu_sha2_init (sha2_t *ctx);
-
-/**
- * Process the Hash
- * \param ctx the module context.
- * \param data the data to hash.
- * \param length the length in bytes.
- */
-void
-cp_secu_sha2_process (sha2_t *ctx, u8 *data, uint length);
-
-#endif /* cp2_secu_inc_sha256_h */
-=======
#ifndef _SHA256_H
#define _SHA256_H
@@ -64,4 +23,3 @@ void sha256_finish( sha256_context *ctx, uint8 digest[32] );
#endif /* sha256.h */
->>>>>>> cp2/secu : tested the SHA256.:cp2/secu/inc/sha256.h
diff --git a/cesar/cp2/secu/sha256.h b/cesar/cp2/secu/sha256.h
index 06d0ccdef7..6c904fb17b 100644
--- a/cesar/cp2/secu/sha256.h
+++ b/cesar/cp2/secu/sha256.h
@@ -17,17 +17,9 @@
/** SHA 256
* \param data the buffer containing the data to hash.
-<<<<<<< HEAD:cp2/secu/sha256.h
- * \param length the length of the data.
- * \return the buffer with the hashed value.
- */
-void
-cp_secu_sha256 (u8 *data, uint length);
-=======
* \return the buffer with the hashed value.
*/
void
cp_secu_sha256 (u8 *data);
->>>>>>> cp2/secu : tested the SHA256.:cp2/secu/sha256.h
#endif /* cp2_secu_sha256_h */
diff --git a/cesar/cp2/secu/src/sha256.c b/cesar/cp2/secu/src/sha256.c
index a095d5c31a..77f4886c87 100644
--- a/cesar/cp2/secu/src/sha256.c
+++ b/cesar/cp2/secu/src/sha256.c
@@ -1,51 +1,3 @@
-<<<<<<< HEAD:cp2/secu/src/sha256.c
-/* Cesar project {{{
- *
- * Copyright (C) 2008 Spidcom
- *
- * <<<Licence>>>
- *
- * }}} */
-/**
- * \file cp2/secu/src/sha256.c
- * \brief SHA 256
- * \ingroup cp2_secu
- *
- * see http://en.wikipedia.org/wiki/SHA256#SHA-2
- */
-#include "common/std.h"
-#include "lib/read_word.h"
-#include "lib/swap.h"
-#include "string.h"
-#include "stdio.h"
-
-#include "cp2/secu/sha256.h"
-#include "cp2/secu/inc/sha256.h"
-
-static const uint
-round_const [64] = {0x428a2f98, 0x71374491, 0xb5c0fbcf, 0xe9b5dba5,
- 0x3956c25b, 0x59f111f1, 0x923f82a4, 0xab1c5ed5, 0xd807aa98, 0x12835b01,
- 0x243185be, 0x550c7dc3, 0x72be5d74, 0x80deb1fe, 0x9bdc06a7, 0xc19bf174,
- 0xe49b69c1, 0xefbe4786, 0x0fc19dc6, 0x240ca1cc, 0x2de92c6f, 0x4a7484aa,
- 0x5cb0a9dc, 0x76f988da, 0x983e5152, 0xa831c66d, 0xb00327c8, 0xbf597fc7,
- 0xc6e00bf3, 0xd5a79147, 0x06ca6351, 0x14292967, 0x27b70a85, 0x2e1b2138,
- 0x4d2c6dfc, 0x53380d13, 0x650a7354, 0x766a0abb, 0x81c2c92e, 0x92722c85,
- 0xa2bfe8a1, 0xa81a664b, 0xc24b8b70, 0xc76c51a3, 0xd192e819, 0xd6990624,
- 0xf40e3585, 0x106aa070, 0x19a4c116, 0x1e376c08, 0x2748774c, 0x34b0bcb5,
- 0x391c0cb3, 0x4ed8aa4a, 0x5b9cca4f, 0x682e6ff3, 0x748f82ee, 0x78a5636f,
- 0x84c87814, 0x8cc70208, 0x90befffa, 0xa4506ceb, 0xbef9a3f7, 0xc67178f2};
-
-/** Initialise the SHA context.
- *
- * \param ctx the module context.
- */
-void
-cp_secu_sha2_init (sha2_t *ctx)
-{
- dbg_assert(ctx);
-
- /* SHA-256 */
-=======
/*
* FIPS-180-2 compliant SHA-256 implementation
*
@@ -107,7 +59,6 @@ void sha256_starts( sha256_context *ctx )
ctx->total[0] = 0;
ctx->total[1] = 0;
->>>>>>> cp2/secu : tested the SHA256.:cp2/secu/src/sha256.c
ctx->state[0] = 0x6A09E667;
ctx->state[1] = 0xBB67AE85;
ctx->state[2] = 0x3C6EF372;
@@ -118,108 +69,6 @@ void sha256_starts( sha256_context *ctx )
ctx->state[7] = 0x5BE0CD19;
}
-<<<<<<< HEAD:cp2/secu/src/sha256.c
-/**
- * Process the Hash
- * \param ctx the module context.
- * \param data the data to hash.
- * \param length the length in bytes.
- */
-void
-cp_secu_sha2_process (sha2_t *ctx, u8 *data, uint length)
-{
- uint words[64];
- uint i;
- uint s0;
- uint s1;
- uint a,b,c,d,e,f,g,h;
- uint maj, t1, t2, ch;
-
- dbg_assert (ctx);
- dbg_assert (data);
-
- data[length] = 0x80;
- length++;
- i = length * 8;
- memcpy (data + length, &i, sizeof(i));
- length += sizeof (i);
-
- // Break the data into 16 32bit-integer big endian.
- for (i = 0; i < 16; i++)
- {
- words[i] = swap32(read_u32_from_word (data + (i * 4)));
- }
-
- for (i = 16; i < 64; i++)
- {
- s0 = ROR(words[i-15], 7) ^ ROR(words[i-15], 18)
- ^ (words[i-15] >> 3);
- s1 = ROR(words[i-2], 17) ^ ROR(words[i-2], 19)
- ^ (words[i-2] >> 10);
-
- words[i] = words[i-16] + s0 + words[i-7] + s1;
- }
-
- // Initialise hash value for this chunk.
- a = ctx->state[0];
- b = ctx->state[1];
- c = ctx->state[2];
- d = ctx->state[3];
- e = ctx->state[4];
- f = ctx->state[5];
- g = ctx->state[6];
- f = ctx->state[7];
-
- // Main loop.
- for (i = 0; i < 64; i++)
- {
- s0 = ROR(a,2) ^ ROR (a, 13) ^ ROR (a, 22);
- maj = (a & b) ^ (a & c) ^ (b & c);
- t2 = s0 + maj;
- s1 = ROR (e, 6) ^ ROR (e, 11) ^ ROR (e, 25);
- ch = (e & f) ^ ((~e) & g);
- t1 = h + s1 + ch + round_const[i] + words[i];
-
- h = g;
- g = f;
- f = e;
- e = d + t1;
- d = c;
- c = b;
- b = a;
- a = t1 + t2;
- }
-
- ctx->state[0] += a;
- ctx->state[1] += b;
- ctx->state[2] += c;
- ctx->state[3] += d;
- ctx->state[4] += e;
- ctx->state[5] += f;
- ctx->state[6] += g;
- ctx->state[7] += h;
-
- for (i = 0; i < 8; i++)
- memcpy (&data[i * 4], &ctx->state[i], 4);
-}
-
-/** SHA 256
- * \param data the buffer containing the data to hash.
- * \param length the length of the data.
- * \return the buffer with the hashed value.
- */
-void
-cp_secu_sha256 (u8 *data, uint length)
-{
- sha2_t sha;
- dbg_assert (data);
- dbg_assert (length);
-
- cp_secu_sha2_init (&sha);
- cp_secu_sha2_process (&sha, data, length);
-}
-
-=======
void sha256_process( sha256_context *ctx, uint8 data[64] )
{
uint32 temp1, temp2, W[64];
@@ -447,4 +296,3 @@ cp_secu_sha256 (u8 *buffer)
memcpy (buffer, sha256sum, 64);
}
->>>>>>> cp2/secu : tested the SHA256.:cp2/secu/src/sha256.c
diff --git a/cesar/cp2/secu/test/src/test-sha2.c b/cesar/cp2/secu/test/src/test-sha2.c
index 333f783cd5..d05dd77461 100644
--- a/cesar/cp2/secu/test/src/test-sha2.c
+++ b/cesar/cp2/secu/test/src/test-sha2.c
@@ -23,13 +23,6 @@ test_case_sha2 (test_t test)
{
u8 buffer[64] __attribute__((aligned(64))) =
"The quick brown fox jumps over the lazy dog\0";
-<<<<<<< HEAD:cp2/secu/test/src/test-sha2.c
- uint result [16] = {0xd7a8fbb3, 0x07d78094, 0x69ca9abc,
- 0xb0082e4f, 0x8d5651e4, 0x6d3cdb76, 0x2d02d0bf, 0x37c9e592};
- uint i;
-
- cp_secu_sha256 (buffer, strlen( (char*) buffer));
-=======
uint result [8] = {0xd7a8fbb3, 0x07d78094, 0x69ca9abc,
0xb0082e4f, 0x8d5651e4, 0x6d3cdb76, 0x2d02d0bf, 0x37c9e592};
@@ -46,19 +39,11 @@ test_case_sha2 (test_t test)
uint i;
cp_secu_sha256 (buffer);
->>>>>>> cp2/secu : tested the SHA256.:cp2/secu/test/src/test-sha2.c
test_case_begin (test, "SHA 256");
test_begin (test, "SHA 256")
{
-<<<<<<< HEAD:cp2/secu/test/src/test-sha2.c
- for (i = 0; i < 16; i++)
- {
- test_fail_if (read_u32_from_word (buffer) != result[i],
- "Wrong buffer out value, value read : %x, shall be : %x",
- read_u32_from_word (buffer), result[i]);
-=======
for (i = 0; i < 8; i++)
{
test_fail_if (read_u32_from_word (buffer + i*4) != result[i],
@@ -90,7 +75,6 @@ test_case_sha2 (test_t test)
test_fail_if (read_u32_from_word (buffer3 + i*4) != result3[i],
"Wrong buffer out value, value read : %x, shall be : %x",
read_u32_from_word (buffer3 + i*4), result3[i]);
->>>>>>> cp2/secu : tested the SHA256.:cp2/secu/test/src/test-sha2.c
}
}
test_end;