1

(36 replies, posted in wolfSSL)

Thank you.
I believe the gcc compiler compiles it just fine, so it might be a bug with only the online mbed compiler. Might be worth a question or two to the ARM coders.
Thanks for all of the help with finding the problem; I'll mark the thread as solved.

2

(36 replies, posted in wolfSSL)

I believe I have found the compile issue that was causing unexpected behaviour with the SHA384 ans SHA512 code.
The R2(i) and R(i) macros both add the W["i"] through the use of another macro:

#define R(i) h(i)+=S1(e(i))+Ch(e(i),f(i),g(i))+K[i+j]+(j?blk2(i):blk0(i));\

Where blk0 and blk2 are:

#define blk0(i) (W["i"] = sha512->buffer["i"])
#define blk2(i) (W[i&15] += s1(W[(i-2)&15])+W[(i-7)&15]+s0(W[(i-15)&15])+0)

Apparently, the compiler was not adding the variable to h(i) after assigning W["i"]. Specifically, to fix the code on mbed to work, I moved the word variable assignments to a separate line, then called the word itself to use for modifying h(i) in the next line. Example code below:

#define R2(i) (j?blk2(i):blk384(i));\
    h(i)+=S1(e(i))+Ch(e(i),f(i),g(i))+K[i+j]+W[i&15];\
    d(i)+=h(i);\
    h(i)+=S0(a(i))+Maj(a(i),b(i),c(i))

3

(36 replies, posted in wolfSSL)

I successfully implemented a SHA384 hash algorithm using the mbed platform, but unfortunately, I'm unable to figure out what is different between what is going wrong with the wolfSSL code and the code I have written.

It is written with only the standard mbed includes, and seems to get the right hash and intermediate words. As I said though, reading through the wolfSSL code I'm unable to determine what is different.


#include "mbed.h"

typedef unsigned long long word64;
typedef uint32_t word32;

static const word64 Record[80*8] = {
    //t = 0
    (0x470994ad30873f88), (0xcbbb9d5dc1059ed8), (0x629a292a367cd507), (0x9159015a3070dd17),
    (0xbd03f724be6075f9), (0x67332667ffc00b31), (0x8eb44a8768581511), (0xdb0c2e0d64f98fa7),
    //t = 1
    (0x2e91230306a12ae0), (0x470994ad30873f88), (0xcbbb9d5dc1059ed8), (0x629a292a367cd507),
    (0x5e1b4e1695372b9e), (0xbd03f724be6075f9), (0x67332667ffc00b31), (0x8eb44a8768581511),
    //t = 2
    (0xeebe5d379be707ad), (0x2e91230306a12ae0), (0x470994ad30873f88), (0xcbbb9d5dc1059ed8),
    (0x54074a65aef34336), (0x5e1b4e1695372b9e), (0xbd03f724be6075f9), (0x67332667ffc00b31),
    //t = 3
    (0xe308483153e15ad6), (0xeebe5d379be707ad), (0x2e91230306a12ae0), (0x470994ad30873f88),
    (0x086c5b2d36a89178), (0x54074a65aef34336), (0x5e1b4e1695372b9e), (0xbd03f724be6075f9),
    //t = 4
    (0x3a7a023c593d8479), (0xe308483153e15ad6), (0xeebe5d379be707ad), (0x2e91230306a12ae0),
    (0x8aa1144850633794), (0x086c5b2d36a89178), (0x54074a65aef34336), (0x5e1b4e1695372b9e),
    //t = 5
    (0x333199a85f92b052), (0x3a7a023c593d8479), (0xe308483153e15ad6), (0xeebe5d379be707ad),
    (0x7a6316f0ef047ce7), (0x8aa1144850633794), (0x086c5b2d36a89178), (0x54074a65aef34336),
    //t = 6
    (0x76f0741213dd2ef6), (0x333199a85f92b052), (0x3a7a023c593d8479), (0xe308483153e15ad6),
    (0x74063cba385f0675), (0x7a6316f0ef047ce7), (0x8aa1144850633794), (0x086c5b2d36a89178),
    //t = 7
    (0x02f2a04d3aab1629), (0x76f0741213dd2ef6), (0x333199a85f92b052), (0x3a7a023c593d8479),
    (0x1688b9bf14980fc0), (0x74063cba385f0675), (0x7a6316f0ef047ce7), (0x8aa1144850633794),
    //t = 8
    (0x73e5b2a1704a0349), (0x02f2a04d3aab1629), (0x76f0741213dd2ef6), (0x333199a85f92b052),
    (0xfd00139f705907d0), (0x1688b9bf14980fc0), (0x74063cba385f0675), (0x7a6316f0ef047ce7),
    //t = 9
    (0xbf3f67ba12882648), (0x73e5b2a1704a0349), (0x02f2a04d3aab1629), (0x76f0741213dd2ef6),
    (0x652e311d4f0a4257), (0xfd00139f705907d0), (0x1688b9bf14980fc0), (0x74063cba385f0675),
    //t = 10
    (0x33254508bb2ea48d), (0xbf3f67ba12882648), (0x73e5b2a1704a0349), (0x02f2a04d3aab1629),
    (0x9e18991c4f39f0ba), (0x652e311d4f0a4257), (0xfd00139f705907d0), (0x1688b9bf14980fc0),
    //t = 11
    (0xc1fdb2a0205ea0e5), (0x33254508bb2ea48d), (0xbf3f67ba12882648), (0x73e5b2a1704a0349),
    (0x04732e8bc4044582), (0x9e18991c4f39f0ba), (0x652e311d4f0a4257), (0xfd00139f705907d0),
    //t = 12
    (0x185f9ff038a50f39), (0xc1fdb2a0205ea0e5), (0x33254508bb2ea48d), (0xbf3f67ba12882648),
    (0x8b4acfc4d2b8afe6), (0x04732e8bc4044582), (0x9e18991c4f39f0ba), (0x652e311d4f0a4257),
    //t = 13
    (0xe5f06744c0d7563a), (0x185f9ff038a50f39), (0xc1fdb2a0205ea0e5), (0x33254508bb2ea48d),
    (0x2fa93d1ce9523015), (0x8b4acfc4d2b8afe6), (0x04732e8bc4044582), (0x9e18991c4f39f0ba),
    //t = 14
    (0x7e32dc0e9f414783), (0xe5f06744c0d7563a), (0x185f9ff038a50f39), (0xc1fdb2a0205ea0e5),
    (0x3a9950aaa5e75884), (0x2fa93d1ce9523015), (0x8b4acfc4d2b8afe6), (0x04732e8bc4044582),
    //t = 15
    (0x1eab6159ae87ef6d), (0x7e32dc0e9f414783), (0xe5f06744c0d7563a), (0x185f9ff038a50f39),
    (0x153b895cfbc436c5), (0x3a9950aaa5e75884), (0x2fa93d1ce9523015), (0x8b4acfc4d2b8afe6),
    //t = 16
    (0x33ef2cebbf1739aa), (0x1eab6159ae87ef6d), (0x7e32dc0e9f414783), (0xe5f06744c0d7563a),
    (0x9d1a64baf1d366aa), (0x153b895cfbc436c5), (0x3a9950aaa5e75884), (0x2fa93d1ce9523015),
    //t = 17
    (0x7df1b65f1b87d6ca), (0x33ef2cebbf1739aa), (0x1eab6159ae87ef6d), (0x7e32dc0e9f414783),
    (0x5b6e369d36e8e181), (0x9d1a64baf1d366aa), (0x153b895cfbc436c5), (0x3a9950aaa5e75884),
    //t = 18
    (0x63a24014a34bb0f6), (0x7df1b65f1b87d6ca), (0x33ef2cebbf1739aa), (0x1eab6159ae87ef6d),
    (0xe13e610eae680d85), (0x5b6e369d36e8e181), (0x9d1a64baf1d366aa), (0x153b895cfbc436c5),
    //t = 19
    (0xf1aabd313309509b), (0x63a24014a34bb0f6), (0x7df1b65f1b87d6ca), (0x33ef2cebbf1739aa),
    (0x674385f0d87db94f), (0xe13e610eae680d85), (0x5b6e369d36e8e181), (0x9d1a64baf1d366aa),
    //t = 20
    (0x9ba737ae88a72c64), (0xf1aabd313309509b), (0x63a24014a34bb0f6), (0x7df1b65f1b87d6ca),
    (0x3fc2614c43906c0f), (0x674385f0d87db94f), (0xe13e610eae680d85), (0x5b6e369d36e8e181),
    //t = 21
    (0x042c2dc9a5bf558a), (0x9ba737ae88a72c64), (0xf1aabd313309509b), (0x63a24014a34bb0f6),
    (0x19316bebc88e01f2), (0x3fc2614c43906c0f), (0x674385f0d87db94f), (0xe13e610eae680d85),
    //t = 22
    (0x7799c75acc748c0f), (0x042c2dc9a5bf558a), (0x9ba737ae88a72c64), (0xf1aabd313309509b),
    (0xa7bbd65bf64f58c8), (0x19316bebc88e01f2), (0x3fc2614c43906c0f), (0x674385f0d87db94f),
    //t = 23
    (0xccf99a80f92bf002), (0x7799c75acc748c0f), (0x042c2dc9a5bf558a), (0x9ba737ae88a72c64),
    (0xe52a24fae4e8fc9b), (0xa7bbd65bf64f58c8), (0x19316bebc88e01f2), (0x3fc2614c43906c0f),
    //t = 24
    (0xae993474363efe68), (0xccf99a80f92bf002), (0x7799c75acc748c0f), (0x042c2dc9a5bf558a),
    (0x587f308d58681928), (0xe52a24fae4e8fc9b), (0xa7bbd65bf64f58c8), (0x19316bebc88e01f2),
    //t = 25
    (0x335063d1a2aec92f), (0xae993474363efe68), (0xccf99a80f92bf002), (0x7799c75acc748c0f),
    (0xc2d6d65e38c6ea79), (0x587f308d58681928), (0xe52a24fae4e8fc9b), (0xa7bbd65bf64f58c8),
    //t = 26
    (0x53a78b0cca01ba37), (0x335063d1a2aec92f), (0xae993474363efe68), (0xccf99a80f92bf002),
    (0x3b65a26c3c92c8f3), (0xc2d6d65e38c6ea79), (0x587f308d58681928), (0xe52a24fae4e8fc9b),
    (0xab7ffa529f622930), (0x53a78b0cca01ba37), (0x335063d1a2aec92f), (0xae993474363efe68),
    (0xb9d8a2f2762901ea), (0x3b65a26c3c92c8f3), (0xc2d6d65e38c6ea79), (0x587f308d58681928),
    (0xe428bb43afe3d63e), (0xab7ffa529f622930), (0x53a78b0cca01ba37), (0x335063d1a2aec92f),
    (0x6a8527525f898726), (0xb9d8a2f2762901ea), (0x3b65a26c3c92c8f3), (0xc2d6d65e38c6ea79),
    (0xbbed541a5128088c), (0xe428bb43afe3d63e), (0xab7ffa529f622930), (0x53a78b0cca01ba37),
    (0x7973aadbde294be9), (0x6a8527525f898726), (0xb9d8a2f2762901ea), (0x3b65a26c3c92c8f3),
    (0x4c5c38df7ec8baf4), (0xbbed541a5128088c), (0xe428bb43afe3d63e), (0xab7ffa529f622930),
    (0x422ceea0200e9ee4), (0x7973aadbde294be9), (0x6a8527525f898726), (0xb9d8a2f2762901ea),
    (0x4ba456ec244033ed), (0x4c5c38df7ec8baf4), (0xbbed541a5128088c), (0xe428bb43afe3d63e),
    (0x7cf40857056d86b0), (0x422ceea0200e9ee4), (0x7973aadbde294be9), (0x6a8527525f898726),
    (0xaa4a6ab2ac5f5dd8), (0x4ba456ec244033ed), (0x4c5c38df7ec8baf4), (0xbbed541a5128088c),
    (0xad2b1ecfb5bfc556), (0x7cf40857056d86b0), (0x422ceea0200e9ee4), (0x7973aadbde294be9),
    (0x9cb941f2ced774b3), (0xaa4a6ab2ac5f5dd8), (0x4ba456ec244033ed), (0x4c5c38df7ec8baf4),
    (0x029f66c7b4569bf0), (0xad2b1ecfb5bfc556), (0x7cf40857056d86b0), (0x422ceea0200e9ee4),
    (0x39265f358594de27), (0x9cb941f2ced774b3), (0xaa4a6ab2ac5f5dd8), (0x4ba456ec244033ed),
    (0x3f7b1c260c82e54f), (0x029f66c7b4569bf0), (0xad2b1ecfb5bfc556), (0x7cf40857056d86b0),
    (0x09cca487d39b02a1), (0x39265f358594de27), (0x9cb941f2ced774b3), (0xaa4a6ab2ac5f5dd8),
    (0x4a22b37b58a5b1b0), (0x3f7b1c260c82e54f), (0x029f66c7b4569bf0), (0xad2b1ecfb5bfc556),
    (0xd48d97ce438cf4f0), (0x09cca487d39b02a1), (0x39265f358594de27), (0x9cb941f2ced774b3),
    (0xa239e00b8baa0410), (0x4a22b37b58a5b1b0), (0x3f7b1c260c82e54f), (0x029f66c7b4569bf0),
    (0xd6f41e25a8b634d6), (0xd48d97ce438cf4f0), (0x09cca487d39b02a1), (0x39265f358594de27),
    (0x25755cb8179dd0b0), (0xa239e00b8baa0410), (0x4a22b37b58a5b1b0), (0x3f7b1c260c82e54f),
    (0x54078334358573b4), (0xd6f41e25a8b634d6), (0xd48d97ce438cf4f0), (0x09cca487d39b02a1),
    (0x0e419fb0802b0efc), (0x25755cb8179dd0b0), (0xa239e00b8baa0410), (0x4a22b37b58a5b1b0),
    (0xdb24f9a03f4fff6b), (0x54078334358573b4), (0xd6f41e25a8b634d6), (0xd48d97ce438cf4f0),
    (0xd30e99b4b394b090), (0x0e419fb0802b0efc), (0x25755cb8179dd0b0), (0xa239e00b8baa0410),
    (0x3604c53a845efc37), (0xdb24f9a03f4fff6b), (0x54078334358573b4), (0xd6f41e25a8b634d6),
    (0x791b2b4af7338b99), (0xd30e99b4b394b090), (0x0e419fb0802b0efc), (0x25755cb8179dd0b0),
    (0xf41b1c0eee89bdc6), (0x3604c53a845efc37), (0xdb24f9a03f4fff6b), (0x54078334358573b4),
    (0xe319b77d9e4e87f9), (0x791b2b4af7338b99), (0xd30e99b4b394b090), (0x0e419fb0802b0efc),
    (0x36644ae374632e3a), (0xf41b1c0eee89bdc6), (0x3604c53a845efc37), (0xdb24f9a03f4fff6b),
    (0x458250878a3972b2), (0xe319b77d9e4e87f9), (0x791b2b4af7338b99), (0xd30e99b4b394b090),
    (0x88806f6ae9fcd65b), (0x36644ae374632e3a), (0xf41b1c0eee89bdc6), (0x3604c53a845efc37),
    (0xcfde2e6ea54fa576), (0x458250878a3972b2), (0xe319b77d9e4e87f9), (0x791b2b4af7338b99),
    (0x51dcaa36995c301d), (0x88806f6ae9fcd65b), (0x36644ae374632e3a), (0xf41b1c0eee89bdc6),
    (0xe37f778353998050), (0xcfde2e6ea54fa576), (0x458250878a3972b2), (0xe319b77d9e4e87f9),
    (0xef5e3885a2f238df), (0x51dcaa36995c301d), (0x88806f6ae9fcd65b), (0x36644ae374632e3a),
    (0x740e347f24e18fda), (0xe37f778353998050), (0xcfde2e6ea54fa576), (0x458250878a3972b2),
    (0xeb3753f4283f4818), (0xef5e3885a2f238df), (0x51dcaa36995c301d), (0x88806f6ae9fcd65b),
    (0x0ae48cf840bb8be9), (0x740e347f24e18fda), (0xe37f778353998050), (0xcfde2e6ea54fa576),
    (0xa6998d63a5d09e04), (0xeb3753f4283f4818), (0xef5e3885a2f238df), (0x51dcaa36995c301d),
    (0xe21095012ee0b72a), (0x0ae48cf840bb8be9), (0x740e347f24e18fda), (0xe37f778353998050),
    (0xd3698fb64df175b0), (0xa6998d63a5d09e04), (0xeb3753f4283f4818), (0xef5e3885a2f238df),
    (0xc2f0b90ffce80739), (0xe21095012ee0b72a), (0x0ae48cf840bb8be9), (0x740e347f24e18fda),
    (0x317a3b295b991914), (0xd3698fb64df175b0), (0xa6998d63a5d09e04), (0xeb3753f4283f4818),
    (0x1cadff2e6cb5aa4d), (0xc2f0b90ffce80739), (0xe21095012ee0b72a), (0x0ae48cf840bb8be9),
    (0x0941da08148ba463), (0x317a3b295b991914), (0xd3698fb64df175b0), (0xa6998d63a5d09e04),
    (0x833eb9a4bb5a073e), (0x1cadff2e6cb5aa4d), (0xc2f0b90ffce80739), (0xe21095012ee0b72a),
    (0x494ac238d68c3d0b), (0x0941da08148ba463), (0x317a3b295b991914), (0xd3698fb64df175b0),
    (0x80c8fc138e645028), (0x833eb9a4bb5a073e), (0x1cadff2e6cb5aa4d), (0xc2f0b90ffce80739),
    (0xc87e9168db9e97de), (0x494ac238d68c3d0b), (0x0941da08148ba463), (0x317a3b295b991914),
    (0x65cf7f6a829aca04), (0x80c8fc138e645028), (0x833eb9a4bb5a073e), (0x1cadff2e6cb5aa4d),
    (0xedb4448879391dbb), (0xc87e9168db9e97de), (0x494ac238d68c3d0b), (0x0941da08148ba463),
    (0x7729c85475dd318f), (0x65cf7f6a829aca04), (0x80c8fc138e645028), (0x833eb9a4bb5a073e),
    (0x073775c2456dc7db), (0xedb4448879391dbb), (0xc87e9168db9e97de), (0x494ac238d68c3d0b),
    (0xa9cca0b6266b1d77), (0x7729c85475dd318f), (0x65cf7f6a829aca04), (0x80c8fc138e645028),
    (0x54de8857b24afaf7), (0x073775c2456dc7db), (0xedb4448879391dbb), (0xc87e9168db9e97de),
    (0x8de51cff2ae4b068), (0xa9cca0b6266b1d77), (0x7729c85475dd318f), (0x65cf7f6a829aca04),
    (0x8a9cdd80f7f09c05), (0x54de8857b24afaf7), (0x073775c2456dc7db), (0xedb4448879391dbb),
    (0xa60ba5e9ebaeb96a), (0x8de51cff2ae4b068), (0xa9cca0b6266b1d77), (0x7729c85475dd318f),
    (0x3eeb22a7524d8d7f), (0x8a9cdd80f7f09c05), (0x54de8857b24afaf7), (0x073775c2456dc7db),
    (0xe2e6830b139df58f), (0xa60ba5e9ebaeb96a), (0x8de51cff2ae4b068), (0xa9cca0b6266b1d77),
    (0x0ed77c9cde8883d3), (0x3eeb22a7524d8d7f), (0x8a9cdd80f7f09c05), (0x54de8857b24afaf7),
    (0x38413a2052387a9e), (0xe2e6830b139df58f), (0xa60ba5e9ebaeb96a), (0x8de51cff2ae4b068),
    (0xe64e4135f9d30dbc), (0x0ed77c9cde8883d3), (0x3eeb22a7524d8d7f), (0x8a9cdd80f7f09c05),
    (0x45b640454c75c349), (0x38413a2052387a9e), (0xe2e6830b139df58f), (0xa60ba5e9ebaeb96a),
    (0x1ca93a293d544328), (0xe64e4135f9d30dbc), (0x0ed77c9cde8883d3), (0x3eeb22a7524d8d7f),
    (0xefbef83a35c0319e), (0x45b640454c75c349), (0x38413a2052387a9e), (0xe2e6830b139df58f),
    (0x3dc764f89e54043a), (0x1ca93a293d544328), (0xe64e4135f9d30dbc), (0x0ed77c9cde8883d3),
    (0xa57784945550cf94), (0xefbef83a35c0319e), (0x45b640454c75c349), (0x38413a2052387a9e),
    (0x56fb5883f1c87a05), (0x3dc764f89e54043a), (0x1ca93a293d544328), (0xe64e4135f9d30dbc),
    (0xf5198a41eb80e022), (0xa57784945550cf94), (0xefbef83a35c0319e), (0x45b640454c75c349),
    (0x24a1124262a331c7), (0x56fb5883f1c87a05), (0x3dc764f89e54043a), (0x1ca93a293d544328),
    (0x06edacae6e7b54ad), (0xf5198a41eb80e022), (0xa57784945550cf94), (0xefbef83a35c0319e),
    (0xeb85d19201c89694), (0x24a1124262a331c7), (0x56fb5883f1c87a05), (0x3dc764f89e54043a),
    (0x9ced24983eec8723), (0x06edacae6e7b54ad), (0xf5198a41eb80e022), (0xa57784945550cf94),
    (0xcc981ab3a59c1db4), (0xeb85d19201c89694), (0x24a1124262a331c7), (0x56fb5883f1c87a05),
    (0xeac5516336bc8882), (0x9ced24983eec8723), (0x06edacae6e7b54ad), (0xf5198a41eb80e022),
    (0xceef5d997e148b44), (0xcc981ab3a59c1db4), (0xeb85d19201c89694), (0x24a1124262a331c7),
    (0x617bbf70bb165212), (0xeac5516336bc8882), (0x9ced24983eec8723), (0x06edacae6e7b54ad),
    (0x689edf608a8e3f14), (0xceef5d997e148b44), (0xcc981ab3a59c1db4), (0xeb85d19201c89694),
    (0x3280d88472c100fd), (0x617bbf70bb165212), (0xeac5516336bc8882), (0x9ced24983eec8723),
    (0x1e6e0255ab88079f), (0x689edf608a8e3f14), (0xceef5d997e148b44), (0xcc981ab3a59c1db4),
    (0xf2001138439902b1), (0x3280d88472c100fd), (0x617bbf70bb165212), (0xeac5516336bc8882),
    (0x8c5d3b7fdad66e70), (0x1e6e0255ab88079f), (0x689edf608a8e3f14), (0xceef5d997e148b44),
    (0x90d18ec8b69f0345), (0xf2001138439902b1), (0x3280d88472c100fd), (0x617bbf70bb165212),
    (0x32e5ed8655871e9b), (0x8c5d3b7fdad66e70), (0x1e6e0255ab88079f), (0x689edf608a8e3f14),
    (0x51105f6241313777), (0x90d18ec8b69f0345), (0xf2001138439902b1), (0x3280d88472c100fd),
    (0xbcd5061679be7336), (0x32e5ed8655871e9b), (0x8c5d3b7fdad66e70), (0x1e6e0255ab88079f),
    (0x454b99f654443ad0), (0x51105f6241313777), (0x90d18ec8b69f0345), (0xf2001138439902b1),
    (0xe7d913b6678e78ef), (0xbcd5061679be7336), (0x32e5ed8655871e9b), (0x8c5d3b7fdad66e70),
    (0x1ff613b5aa63776e), (0x454b99f654443ad0), (0x51105f6241313777), (0x90d18ec8b69f0345),
    (0xe6b8cb8dfa3475ab), (0xe7d913b6678e78ef), (0xbcd5061679be7336), (0x32e5ed8655871e9b),
    (0x2e75f34303d39bb0), (0x1ff613b5aa63776e), (0x454b99f654443ad0), (0x51105f6241313777),
    (0xfdd4a30e168c4ae5), (0xe6b8cb8dfa3475ab), (0xe7d913b6678e78ef), (0xbcd5061679be7336),
    (0x83a35dbe2a64fc26), (0x2e75f34303d39bb0), (0x1ff613b5aa63776e), (0x454b99f654443ad0),
    (0x12aeb6268dfa3e14), (0xfdd4a30e168c4ae5), (0xe6b8cb8dfa3475ab), (0xe7d913b6678e78ef),
    (0xf660943b276786f7), (0x83a35dbe2a64fc26), (0x2e75f34303d39bb0), (0x1ff613b5aa63776e),
    (0x055b73814cf102b4), (0x12aeb6268dfa3e14), (0xfdd4a30e168c4ae5), (0xe6b8cb8dfa3475ab),
    (0xc4b149710f5d6a71), (0xf660943b276786f7), (0x83a35dbe2a64fc26), (0x2e75f34303d39bb0),
    (0x95d33150de6df44c), (0x055b73814cf102b4), (0x12aeb6268dfa3e14), (0xfdd4a30e168c4ae5),
    (0xc7f7bff08ebf0d30), (0xc4b149710f5d6a71), (0xf660943b276786f7), (0x83a35dbe2a64fc26),
    (0x5306143f64497b00), (0x95d33150de6df44c), (0x055b73814cf102b4), (0x12aeb6268dfa3e14),
    (0xca06a219cc701096), (0xc7f7bff08ebf0d30), (0xc4b149710f5d6a71), (0xf660943b276786f7),
    (0xff44d7e1849dbfb3), (0x5306143f64497b00), (0x95d33150de6df44c), (0x055b73814cf102b4),
    (0x1952e0c3a227c0f2), (0xca06a219cc701096), (0xc7f7bff08ebf0d30), (0xc4b149710f5d6a71)
};
static const word64 K512[80] = {
    (0x428a2f98d728ae22), (0x7137449123ef65cd),
    (0xb5c0fbcfec4d3b2f), (0xe9b5dba58189dbbc),
    (0x3956c25bf348b538), (0x59f111f1b605d019),
    (0x923f82a4af194f9b), (0xab1c5ed5da6d8118),
    (0xd807aa98a3030242), (0x12835b0145706fbe),
    (0x243185be4ee4b28c), (0x550c7dc3d5ffb4e2),
    (0x72be5d74f27b896f), (0x80deb1fe3b1696b1),
    (0x9bdc06a725c71235), (0xc19bf174cf692694),
    (0xe49b69c19ef14ad2), (0xefbe4786384f25e3),
    (0x0fc19dc68b8cd5b5), (0x240ca1cc77ac9c65),
    (0x2de92c6f592b0275), (0x4a7484aa6ea6e483),
    (0x5cb0a9dcbd41fbd4), (0x76f988da831153b5),
    (0x983e5152ee66dfab), (0xa831c66d2db43210),
    (0xb00327c898fb213f), (0xbf597fc7beef0ee4),
    (0xc6e00bf33da88fc2), (0xd5a79147930aa725),
    (0x06ca6351e003826f), (0x142929670a0e6e70),
    (0x27b70a8546d22ffc), (0x2e1b21385c26c926),
    (0x4d2c6dfc5ac42aed), (0x53380d139d95b3df),
    (0x650a73548baf63de), (0x766a0abb3c77b2a8),
    (0x81c2c92e47edaee6), (0x92722c851482353b),
    (0xa2bfe8a14cf10364), (0xa81a664bbc423001),
    (0xc24b8b70d0f89791), (0xc76c51a30654be30),
    (0xd192e819d6ef5218), (0xd69906245565a910),
    (0xf40e35855771202a), (0x106aa07032bbd1b8),
    (0x19a4c116b8d2d0c8), (0x1e376c085141ab53),
    (0x2748774cdf8eeb99), (0x34b0bcb5e19b48a8),
    (0x391c0cb3c5c95a63), (0x4ed8aa4ae3418acb),
    (0x5b9cca4f7763e373), (0x682e6ff3d6b2b8a3),
    (0x748f82ee5defb2fc), (0x78a5636f43172f60),
    (0x84c87814a1f0ab72), (0x8cc702081a6439ec),
    (0x90befffa23631e28), (0xa4506cebde82bde9),
    (0xbef9a3f7b2c67915), (0xc67178f2e372532b),
    (0xca273eceea26619c), (0xd186b8c721c0c207),
    (0xeada7dd6cde0eb1e), (0xf57d4f7fee6ed178),
    (0x06f067aa72176fba), (0x0a637dc5a2c898a6),
    (0x113f9804bef90dae), (0x1b710b35131c471b),
    (0x28db77f523047d84), (0x32caab7b40c72493),
    (0x3c9ebe0a15c9bebc), (0x431d67c49c100d4c),
    (0x4cc5d4becb3e42b6), (0x597f299cfc657e2a),
    (0x5fcb6fab3ad6faec), (0x6c44198c4a475817)
};
word64 rotrFixed64(word64 x, word64 y)
{
    return (x >> y) | (x << (sizeof(y) * 8 - y));
}

int main(){
    printf("Size of word64 %d\r\n",sizeof(word64));
    printf("Size of word32 %d\r\n",sizeof(word32));
    
    printf("Checking bitwise operators\r\n");
    printf("Test \"AND\" %llX = 0xA0C0E00234128000\r\n",(0xABCDEF1234568888)&(0xA0C0E00234128040));
    printf("Test \"OR\"  %llX = 0x514789485ABEFDCE\r\n",(0x110388004882D586)|(0x40440148123C2848));
    printf("Text \"XOR\" %llX = 0x2531253186752093\r\n",(0xFFFFFFFF11111111)^(0xDACEDACE97643182));
    printf("Text \"NOT\" %llX = 0xFEDCBA9876543210\r\n",~(0x0123456789ABCDEF));
    printf("1 shifted right 61 bits: %llX = 0x0000000000000008\r\n", rotrFixed64(0x0000000000000001,61));
    printf("ABC shifted right 32 bits: %llX = 0x00000ABC00000000\r\n", rotrFixed64(0x0000000000000ABC,32));
    printf("1 shifted right 1 bits: %llX = 0x8000000000000000\r\n", rotrFixed64(0x0000000000000001,1));
    printf("1 shifted right 3 bits: %llX = 0x2000000000000000\r\n", rotrFixed64(0x0000000000000001,3));
    
    const word64* K = K512;
    word64 T[8];
    T[0] = (0xcbbb9d5dc1059ed8);
    T[1] = (0x629a292a367cd507);
    T[2] = (0x9159015a3070dd17);
    T[3] = (0x152fecd8f70e5939);
    T[4] = (0x67332667ffc00b31);
    T[5] = (0x8eb44a8768581511);
    T[6] = (0xdb0c2e0d64f98fa7);
    T[7] = (0x47b5481dbefa4fa4);
    printf("Testing SHA384 calculations:\r\n");
    
        word64 Word[16];
        Word[0] = 0x6162638000000000;
        Word[1] = 0;
        Word[2] = 0;
        Word[3] = 0;
        Word[4] = 0;
        Word[5] = 0;
        Word[6] = 0;
        Word[7] = 0;
        Word[8] = 0;
        Word[9] = 0;
        Word[10] = 0;
        Word[11] = 0;
        Word[12] = 0;
        Word[13] = 0;
        Word[14] = 0;
        Word[15] = 0x18;
        word64 Ch,Maj,Sum0,Sum1;
        word64 Temp1, Temp2;
        //printf("init\t%016llX\t%016llX\t%016llX\t%016llX\r\n",A,B,C,D);
        //printf("\t%016llX\t%016llX\t%016llX\t%016llX\r\n",E,F,G,H);
        for(int j=0; j<80; j++) {
            Ch = ((T[4] & T[5])^((~T[4]) & T[6]));
            Maj = ((T[0]&T[1])^(T[0]&T[2])^(T[1]&T[2]));
            Sum0 = (rotrFixed64(T[0],28)^rotrFixed64(T[0],34)^rotrFixed64(T[0],39));
            Sum1 = (rotrFixed64(T[4],14)^rotrFixed64(T[4],18)^rotrFixed64(T[4],41));
            if(j < 16) {
                Word[j] = Word[j]; //Initialize value
            } else {
                word64 s1 = rotrFixed64(Word[(j-2)&15],19)^rotrFixed64(Word[(j-2)&15],61)^(Word[(j-2)&15]>>6); //S19^S61^R6
                word64 s0 = rotrFixed64(Word[(j-15)&15],1)^rotrFixed64(Word[(j-15)&15],8)^(Word[(j-15)&15]>>7); //S1^S8^R7
                
                Word[j&15] = s1 + Word[(j-7)&15] + s0 + Word[(j-16)&15];
            }
            
            Temp1 = T[7] + Sum1 + Ch + K[j] + Word[(j)&(0xF)];
            Temp2 = Sum0 + Maj;
            
            T[7] = T[6];
            T[6] = T[5];
            T[5] = T[4];
            T[4] = T[3] + Temp1;
            T[3] = T[2];
            T[2] = T[1];
            T[1] = T[0];
            T[0] = Temp1 + Temp2;
            printf("t = %d\t%016llX\t%016llX\t%016llX\t%016llX\r\n",j,T[0],T[1],T[2],T[3]);
            printf("\t%016llX\t%016llX\t%016llX\t%016llX\r\n",T[4],T[5],T[6],T[7]);
        }
        printf("Hash(0): %llX\r\n",T[0] + (0xcbbb9d5dc1059ed8));
        printf("Hash(1): %llX\r\n",T[1] + (0x629a292a367cd507));
        printf("Hash(2): %llX\r\n",T[2] + (0x9159015a3070dd17));
        printf("Hash(3): %llX\r\n",T[3] + (0x152fecd8f70e5939));
        printf("Hash(4): %llX\r\n",T[4] + (0x67332667ffc00b31));
        printf("Hash(5): %llX\r\n",T[5] + (0x8eb44a8768581511));
        printf("Hash(6): %llX\r\n",T[6] + (0xdb0c2e0d64f98fa7));
        printf("Hash(7): %llX\r\n",T[7] + (0x47b5481dbefa4fa4));
}

Results of the code:

Size of word64 8
Size of word32 4
Checking bitwise operators
Test "AND" A0C0E00234128000 = 0xA0C0E00234128000
Test "OR"  514789485ABEFDCE = 0x514789485ABEFDCE
Text "XOR" 2531253186752093 = 0x2531253186752093
Text "NOT" FEDCBA9876543210 = 0xFEDCBA9876543210
1 shifted right 61 bits: 8 = 0x0000000000000008
ABC shifted right 32 bits: ABC00000000 = 0x00000ABC00000000
1 shifted right 1 bits: 8000000000000000 = 0x8000000000000000
1 shifted right 3 bits: 2000000000000000 = 0x2000000000000000
Testing SHA384 calculations:
t = 0   470994AD30873F88        CBBB9D5DC1059ED8        629A292A367CD507        9159015A3070DD17
        BD03F724BE6075F9        67332667FFC00B31        8EB44A8768581511        DB0C2E0D64F98FA7
t = 1   2E91230306A12AE0        470994AD30873F88        CBBB9D5DC1059ED8        629A292A367CD507
        5E1B4E1695372B9E        BD03F724BE6075F9        67332667FFC00B31        8EB44A8768581511
t = 2   EEBE5D379BE707AD        2E91230306A12AE0        470994AD30873F88        CBBB9D5DC1059ED8
        54074A65AEF34336        5E1B4E1695372B9E        BD03F724BE6075F9        67332667FFC00B31
t = 3   E308483153E15AD6        EEBE5D379BE707AD        2E91230306A12AE0        470994AD30873F88
        086C5B2D36A89178        54074A65AEF34336        5E1B4E1695372B9E        BD03F724BE6075F9
t = 4   3A7A023C593D8479        E308483153E15AD6        EEBE5D379BE707AD        2E91230306A12AE0
        8AA1144850633794        086C5B2D36A89178        54074A65AEF34336        5E1B4E1695372B9E
t = 5   333199A85F92B052        3A7A023C593D8479        E308483153E15AD6        EEBE5D379BE707AD
        7A6316F0EF047CE7        8AA1144850633794        086C5B2D36A89178        54074A65AEF34336
t = 6   76F0741213DD2EF6        333199A85F92B052        3A7A023C593D8479        E308483153E15AD6
        74063CBA385F0675        7A6316F0EF047CE7        8AA1144850633794        086C5B2D36A89178
t = 7   02F2A04D3AAB1629        76F0741213DD2EF6        333199A85F92B052        3A7A023C593D8479
        1688B9BF14980FC0        74063CBA385F0675        7A6316F0EF047CE7        8AA1144850633794
t = 8   73E5B2A1704A0349        02F2A04D3AAB1629        76F0741213DD2EF6        333199A85F92B052
        FD00139F705907D0        1688B9BF14980FC0        74063CBA385F0675        7A6316F0EF047CE7
t = 9   BF3F67BA12882648        73E5B2A1704A0349        02F2A04D3AAB1629        76F0741213DD2EF6
        652E311D4F0A4257        FD00139F705907D0        1688B9BF14980FC0        74063CBA385F0675
t = 10  33254508BB2EA48D        BF3F67BA12882648        73E5B2A1704A0349        02F2A04D3AAB1629
        9E18991C4F39F0BA        652E311D4F0A4257        FD00139F705907D0        1688B9BF14980FC0
t = 11  C1FDB2A0205EA0E5        33254508BB2EA48D        BF3F67BA12882648        73E5B2A1704A0349
        04732E8BC4044582        9E18991C4F39F0BA        652E311D4F0A4257        FD00139F705907D0
t = 12  185F9FF038A50F39        C1FDB2A0205EA0E5        33254508BB2EA48D        BF3F67BA12882648
        8B4ACFC4D2B8AFE6        04732E8BC4044582        9E18991C4F39F0BA        652E311D4F0A4257
t = 13  E5F06744C0D7563A        185F9FF038A50F39        C1FDB2A0205EA0E5        33254508BB2EA48D
        2FA93D1CE9523015        8B4ACFC4D2B8AFE6        04732E8BC4044582        9E18991C4F39F0BA
t = 14  7E32DC0E9F414783        E5F06744C0D7563A        185F9FF038A50F39        C1FDB2A0205EA0E5
        3A9950AAA5E75884        2FA93D1CE9523015        8B4ACFC4D2B8AFE6        04732E8BC4044582
t = 15  1EAB6159AE87EF6D        7E32DC0E9F414783        E5F06744C0D7563A        185F9FF038A50F39
        153B895CFBC436C5        3A9950AAA5E75884        2FA93D1CE9523015        8B4ACFC4D2B8AFE6
t = 16  33EF2CEBBF1739AA        1EAB6159AE87EF6D        7E32DC0E9F414783        E5F06744C0D7563A
        9D1A64BAF1D366AA        153B895CFBC436C5        3A9950AAA5E75884        2FA93D1CE9523015
t = 17  7DF1B65F1B87D6CA        33EF2CEBBF1739AA        1EAB6159AE87EF6D        7E32DC0E9F414783
        5B6E369D36E8E181        9D1A64BAF1D366AA        153B895CFBC436C5        3A9950AAA5E75884
t = 18  63A24014A34BB0F6        7DF1B65F1B87D6CA        33EF2CEBBF1739AA        1EAB6159AE87EF6D
        E13E610EAE680D85        5B6E369D36E8E181        9D1A64BAF1D366AA        153B895CFBC436C5
t = 19  F1AABD313309509B        63A24014A34BB0F6        7DF1B65F1B87D6CA        33EF2CEBBF1739AA
        674385F0D87DB94F        E13E610EAE680D85        5B6E369D36E8E181        9D1A64BAF1D366AA
t = 20  9BA737AE88A72C64        F1AABD313309509B        63A24014A34BB0F6        7DF1B65F1B87D6CA
        3FC2614C43906C0F        674385F0D87DB94F        E13E610EAE680D85        5B6E369D36E8E181
t = 21  042C2DC9A5BF558A        9BA737AE88A72C64        F1AABD313309509B        63A24014A34BB0F6
        19316BEBC88E01F2        3FC2614C43906C0F        674385F0D87DB94F        E13E610EAE680D85
t = 22  7799C75ACC748C0F        042C2DC9A5BF558A        9BA737AE88A72C64        F1AABD313309509B
        A7BBD65BF64F58C8        19316BEBC88E01F2        3FC2614C43906C0F        674385F0D87DB94F
t = 23  CCF99A80F92BF002        7799C75ACC748C0F        042C2DC9A5BF558A        9BA737AE88A72C64
        E52A24FAE4E8FC9B        A7BBD65BF64F58C8        19316BEBC88E01F2        3FC2614C43906C0F
t = 24  AE993474363EFE68        CCF99A80F92BF002        7799C75ACC748C0F        042C2DC9A5BF558A
        587F308D58681928        E52A24FAE4E8FC9B        A7BBD65BF64F58C8        19316BEBC88E01F2
t = 25  335063D1A2AEC92F        AE993474363EFE68        CCF99A80F92BF002        7799C75ACC748C0F
        C2D6D65E38C6EA79        587F308D58681928        E52A24FAE4E8FC9B        A7BBD65BF64F58C8
t = 26  53A78B0CCA01BA37        335063D1A2AEC92F        AE993474363EFE68        CCF99A80F92BF002
        3B65A26C3C92C8F3        C2D6D65E38C6EA79        587F308D58681928        E52A24FAE4E8FC9B
t = 27  AB7FFA529F622930        53A78B0CCA01BA37        335063D1A2AEC92F        AE993474363EFE68
        B9D8A2F2762901EA        3B65A26C3C92C8F3        C2D6D65E38C6EA79        587F308D58681928
t = 28  E428BB43AFE3D63E        AB7FFA529F622930        53A78B0CCA01BA37        335063D1A2AEC92F
        6A8527525F898726        B9D8A2F2762901EA        3B65A26C3C92C8F3        C2D6D65E38C6EA79
t = 29  BBED541A5128088C        E428BB43AFE3D63E        AB7FFA529F622930        53A78B0CCA01BA37
        7973AADBDE294BE9        6A8527525F898726        B9D8A2F2762901EA        3B65A26C3C92C8F3
t = 30  4C5C38DF7EC8BAF4        BBED541A5128088C        E428BB43AFE3D63E        AB7FFA529F622930
        422CEEA0200E9EE4        7973AADBDE294BE9        6A8527525F898726        B9D8A2F2762901EA
t = 31  4BA456EC244033ED        4C5C38DF7EC8BAF4        BBED541A5128088C        E428BB43AFE3D63E
        7CF40857056D86B0        422CEEA0200E9EE4        7973AADBDE294BE9        6A8527525F898726
t = 32  AA4A6AB2AC5F5DD8        4BA456EC244033ED        4C5C38DF7EC8BAF4        BBED541A5128088C
        AD2B1ECFB5BFC556        7CF40857056D86B0        422CEEA0200E9EE4        7973AADBDE294BE9
t = 33  9CB941F2CED774B3        AA4A6AB2AC5F5DD8        4BA456EC244033ED        4C5C38DF7EC8BAF4
        029F66C7B4569BF0        AD2B1ECFB5BFC556        7CF40857056D86B0        422CEEA0200E9EE4
t = 34  39265F358594DE27        9CB941F2CED774B3        AA4A6AB2AC5F5DD8        4BA456EC244033ED
        3F7B1C260C82E54F        029F66C7B4569BF0        AD2B1ECFB5BFC556        7CF40857056D86B0
t = 35  09CCA487D39B02A1        39265F358594DE27        9CB941F2CED774B3        AA4A6AB2AC5F5DD8
        4A22B37B58A5B1B0        3F7B1C260C82E54F        029F66C7B4569BF0        AD2B1ECFB5BFC556
t = 36  D48D97CE438CF4F0        09CCA487D39B02A1        39265F358594DE27        9CB941F2CED774B3
        A239E00B8BAA0410        4A22B37B58A5B1B0        3F7B1C260C82E54F        029F66C7B4569BF0
t = 37  D6F41E25A8B634D6        D48D97CE438CF4F0        09CCA487D39B02A1        39265F358594DE27
        25755CB8179DD0B0        A239E00B8BAA0410        4A22B37B58A5B1B0        3F7B1C260C82E54F
t = 38  54078334358573B4        D6F41E25A8B634D6        D48D97CE438CF4F0        09CCA487D39B02A1
        0E419FB0802B0EFC        25755CB8179DD0B0        A239E00B8BAA0410        4A22B37B58A5B1B0
t = 39  DB24F9A03F4FFF6B        54078334358573B4        D6F41E25A8B634D6        D48D97CE438CF4F0
        D30E99B4B394B090        0E419FB0802B0EFC        25755CB8179DD0B0        A239E00B8BAA0410
t = 40  3604C53A845EFC37        DB24F9A03F4FFF6B        54078334358573B4        D6F41E25A8B634D6
        791B2B4AF7338B99        D30E99B4B394B090        0E419FB0802B0EFC        25755CB8179DD0B0
t = 41  F41B1C0EEE89BDC6        3604C53A845EFC37        DB24F9A03F4FFF6B        54078334358573B4
        E319B77D9E4E87F9        791B2B4AF7338B99        D30E99B4B394B090        0E419FB0802B0EFC
t = 42  36644AE374632E3A        F41B1C0EEE89BDC6        3604C53A845EFC37        DB24F9A03F4FFF6B
        458250878A3972B2        E319B77D9E4E87F9        791B2B4AF7338B99        D30E99B4B394B090
t = 43  88806F6AE9FCD65B        36644AE374632E3A        F41B1C0EEE89BDC6        3604C53A845EFC37
        CFDE2E6EA54FA576        458250878A3972B2        E319B77D9E4E87F9        791B2B4AF7338B99
t = 44  51DCAA36995C301D        88806F6AE9FCD65B        36644AE374632E3A        F41B1C0EEE89BDC6
        E37F778353998050        CFDE2E6EA54FA576        458250878A3972B2        E319B77D9E4E87F9
t = 45  EF5E3885A2F238DF        51DCAA36995C301D        88806F6AE9FCD65B        36644AE374632E3A
        740E347F24E18FDA        E37F778353998050        CFDE2E6EA54FA576        458250878A3972B2
t = 46  EB3753F4283F4818        EF5E3885A2F238DF        51DCAA36995C301D        88806F6AE9FCD65B
        0AE48CF840BB8BE9        740E347F24E18FDA        E37F778353998050        CFDE2E6EA54FA576
t = 47  A6998D63A5D09E04        EB3753F4283F4818        EF5E3885A2F238DF        51DCAA36995C301D
        E21095012EE0B72A        0AE48CF840BB8BE9        740E347F24E18FDA        E37F778353998050
t = 48  D3698FB64DF175B0        A6998D63A5D09E04        EB3753F4283F4818        EF5E3885A2F238DF
        C2F0B90FFCE80739        E21095012EE0B72A        0AE48CF840BB8BE9        740E347F24E18FDA
t = 49  317A3B295B991914        D3698FB64DF175B0        A6998D63A5D09E04        EB3753F4283F4818
        1CADFF2E6CB5AA4D        C2F0B90FFCE80739        E21095012EE0B72A        0AE48CF840BB8BE9
t = 50  0941DA08148BA463        317A3B295B991914        D3698FB64DF175B0        A6998D63A5D09E04
        833EB9A4BB5A073E        1CADFF2E6CB5AA4D        C2F0B90FFCE80739        E21095012EE0B72A
t = 51  494AC238D68C3D0B        0941DA08148BA463        317A3B295B991914        D3698FB64DF175B0
        80C8FC138E645028        833EB9A4BB5A073E        1CADFF2E6CB5AA4D        C2F0B90FFCE80739
t = 52  C87E9168DB9E97DE        494AC238D68C3D0B        0941DA08148BA463        317A3B295B991914
        65CF7F6A829ACA04        80C8FC138E645028        833EB9A4BB5A073E        1CADFF2E6CB5AA4D
t = 53  EDB4448879391DBB        C87E9168DB9E97DE        494AC238D68C3D0B        0941DA08148BA463
        7729C85475DD318F        65CF7F6A829ACA04        80C8FC138E645028        833EB9A4BB5A073E
t = 54  073775C2456DC7DB        EDB4448879391DBB        C87E9168DB9E97DE        494AC238D68C3D0B
        A9CCA0B6266B1D77        7729C85475DD318F        65CF7F6A829ACA04        80C8FC138E645028
t = 55  54DE8857B24AFAF7        073775C2456DC7DB        EDB4448879391DBB        C87E9168DB9E97DE
        8DE51CFF2AE4B068        A9CCA0B6266B1D77        7729C85475DD318F        65CF7F6A829ACA04
t = 56  8A9CDD80F7F09C05        54DE8857B24AFAF7        073775C2456DC7DB        EDB4448879391DBB
        A60BA5E9EBAEB96A        8DE51CFF2AE4B068        A9CCA0B6266B1D77        7729C85475DD318F
t = 57  3EEB22A7524D8D7F        8A9CDD80F7F09C05        54DE8857B24AFAF7        073775C2456DC7DB
        E2E6830B139DF58F        A60BA5E9EBAEB96A        8DE51CFF2AE4B068        A9CCA0B6266B1D77
t = 58  0ED77C9CDE8883D3        3EEB22A7524D8D7F        8A9CDD80F7F09C05        54DE8857B24AFAF7
        38413A2052387A9E        E2E6830B139DF58F        A60BA5E9EBAEB96A        8DE51CFF2AE4B068
t = 59  E64E4135F9D30DBC        0ED77C9CDE8883D3        3EEB22A7524D8D7F        8A9CDD80F7F09C05
        45B640454C75C349        38413A2052387A9E        E2E6830B139DF58F        A60BA5E9EBAEB96A
t = 60  1CA93A293D544328        E64E4135F9D30DBC        0ED77C9CDE8883D3        3EEB22A7524D8D7F
        EFBEF83A35C0319E        45B640454C75C349        38413A2052387A9E        E2E6830B139DF58F
t = 61  3DC764F89E54043A        1CA93A293D544328        E64E4135F9D30DBC        0ED77C9CDE8883D3
        A57784945550CF94        EFBEF83A35C0319E        45B640454C75C349        38413A2052387A9E
t = 62  56FB5883F1C87A05        3DC764F89E54043A        1CA93A293D544328        E64E4135F9D30DBC
        F5198A41EB80E022        A57784945550CF94        EFBEF83A35C0319E        45B640454C75C349
t = 63  24A1124262A331C7        56FB5883F1C87A05        3DC764F89E54043A        1CA93A293D544328
        06EDACAE6E7B54AD        F5198A41EB80E022        A57784945550CF94        EFBEF83A35C0319E
t = 64  EB85D19201C89694        24A1124262A331C7        56FB5883F1C87A05        3DC764F89E54043A
        9CED24983EEC8723        06EDACAE6E7B54AD        F5198A41EB80E022        A57784945550CF94
t = 65  CC981AB3A59C1DB4        EB85D19201C89694        24A1124262A331C7        56FB5883F1C87A05
        EAC5516336BC8882        9CED24983EEC8723        06EDACAE6E7B54AD        F5198A41EB80E022
t = 66  CEEF5D997E148B44        CC981AB3A59C1DB4        EB85D19201C89694        24A1124262A331C7
        617BBF70BB165212        EAC5516336BC8882        9CED24983EEC8723        06EDACAE6E7B54AD
t = 67  689EDF608A8E3F14        CEEF5D997E148B44        CC981AB3A59C1DB4        EB85D19201C89694
        3280D88472C100FD        617BBF70BB165212        EAC5516336BC8882        9CED24983EEC8723
t = 68  1E6E0255AB88079F        689EDF608A8E3F14        CEEF5D997E148B44        CC981AB3A59C1DB4
        F2001138439902B1        3280D88472C100FD        617BBF70BB165212        EAC5516336BC8882
t = 69  8C5D3B7FDAD66E70        1E6E0255AB88079F        689EDF608A8E3F14        CEEF5D997E148B44
        90D18EC8B69F0345        F2001138439902B1        3280D88472C100FD        617BBF70BB165212
t = 70  32E5ED8655871E9B        8C5D3B7FDAD66E70        1E6E0255AB88079F        689EDF608A8E3F14
        51105F6241313777        90D18EC8B69F0345        F2001138439902B1        3280D88472C100FD
t = 71  BCD5061679BE7336        32E5ED8655871E9B        8C5D3B7FDAD66E70        1E6E0255AB88079F
        454B99F654443AD0        51105F6241313777        90D18EC8B69F0345        F2001138439902B1
t = 72  E7D913B6678E78EF        BCD5061679BE7336        32E5ED8655871E9B        8C5D3B7FDAD66E70
        1FF613B5AA63776E        454B99F654443AD0        51105F6241313777        90D18EC8B69F0345
t = 73  E6B8CB8DFA3475AB        E7D913B6678E78EF        BCD5061679BE7336        32E5ED8655871E9B
        2E75F34303D39BB0        1FF613B5AA63776E        454B99F654443AD0        51105F6241313777
t = 74  FDD4A30E168C4AE5        E6B8CB8DFA3475AB        E7D913B6678E78EF        BCD5061679BE7336
        83A35DBE2A64FC26        2E75F34303D39BB0        1FF613B5AA63776E        454B99F654443AD0
t = 75  12AEB6268DFA3E14        FDD4A30E168C4AE5        E6B8CB8DFA3475AB        E7D913B6678E78EF
        F660943B276786F7        83A35DBE2A64FC26        2E75F34303D39BB0        1FF613B5AA63776E
t = 76  055B73814CF102B4        12AEB6268DFA3E14        FDD4A30E168C4AE5        E6B8CB8DFA3475AB
        C4B149710F5D6A71        F660943B276786F7        83A35DBE2A64FC26        2E75F34303D39BB0
t = 77  95D33150DE6DF44C        055B73814CF102B4        12AEB6268DFA3E14        FDD4A30E168C4AE5
        C7F7BFF08EBF0D30        C4B149710F5D6A71        F660943B276786F7        83A35DBE2A64FC26
t = 78  5306143F64497B00        95D33150DE6DF44C        055B73814CF102B4        12AEB6268DFA3E14
        CA06A219CC701096        C7F7BFF08EBF0D30        C4B149710F5D6A71        F660943B276786F7
t = 79  FF44D7E1849DBFB3        5306143F64497B00        95D33150DE6DF44C        055B73814CF102B4
        1952E0C3A227C0F2        CA06A219CC701096        C7F7BFF08EBF0D30        C4B149710F5D6A71
Hash(0): CB00753F45A35E8B
Hash(1): B5A03D699AC65007
Hash(2): 272C32AB0EDED163
Hash(3): 1A8B605A43FF5BED
Hash(4): 8086072BA1E7CC23
Hash(5): 58BAECA134C825A7
Hash(6): A303EDFDF3B89CD7
Hash(7): C66918ECE57BA15

4

(36 replies, posted in wolfSSL)

I wrote up a test code to run the SHA384 Hash separately from all of the wolfSSL code, pulling out the needed constants and such. It seems as if some values stored in memory are getting corrupted/changed separately from when the code accesses them?

I've attached the test code I ran. On iteration 17, the value for the "C" variable is printed out, showing that the value in memory had the upper half or so of the variable set to 0.

This could be a hardware issue, but I'm hesitant to say it is without positively identifying that the code should be running perfectly.

Test Code:

#include "mbed.h"

typedef unsigned long long word64;
typedef unsigned int   word32;

static const word64 K512[80] = {
    (0x428a2f98d728ae22), (0x7137449123ef65cd),
    (0xb5c0fbcfec4d3b2f), (0xe9b5dba58189dbbc),
    (0x3956c25bf348b538), (0x59f111f1b605d019),
    (0x923f82a4af194f9b), (0xab1c5ed5da6d8118),
    (0xd807aa98a3030242), (0x12835b0145706fbe),
    (0x243185be4ee4b28c), (0x550c7dc3d5ffb4e2),
    (0x72be5d74f27b896f), (0x80deb1fe3b1696b1),
    (0x9bdc06a725c71235), (0xc19bf174cf692694),
    (0xe49b69c19ef14ad2), (0xefbe4786384f25e3),
    (0x0fc19dc68b8cd5b5), (0x240ca1cc77ac9c65),
    (0x2de92c6f592b0275), (0x4a7484aa6ea6e483),
    (0x5cb0a9dcbd41fbd4), (0x76f988da831153b5),
    (0x983e5152ee66dfab), (0xa831c66d2db43210),
    (0xb00327c898fb213f), (0xbf597fc7beef0ee4),
    (0xc6e00bf33da88fc2), (0xd5a79147930aa725),
    (0x06ca6351e003826f), (0x142929670a0e6e70),
    (0x27b70a8546d22ffc), (0x2e1b21385c26c926),
    (0x4d2c6dfc5ac42aed), (0x53380d139d95b3df),
    (0x650a73548baf63de), (0x766a0abb3c77b2a8),
    (0x81c2c92e47edaee6), (0x92722c851482353b),
    (0xa2bfe8a14cf10364), (0xa81a664bbc423001),
    (0xc24b8b70d0f89791), (0xc76c51a30654be30),
    (0xd192e819d6ef5218), (0xd69906245565a910),
    (0xf40e35855771202a), (0x106aa07032bbd1b8),
    (0x19a4c116b8d2d0c8), (0x1e376c085141ab53),
    (0x2748774cdf8eeb99), (0x34b0bcb5e19b48a8),
    (0x391c0cb3c5c95a63), (0x4ed8aa4ae3418acb),
    (0x5b9cca4f7763e373), (0x682e6ff3d6b2b8a3),
    (0x748f82ee5defb2fc), (0x78a5636f43172f60),
    (0x84c87814a1f0ab72), (0x8cc702081a6439ec),
    (0x90befffa23631e28), (0xa4506cebde82bde9),
    (0xbef9a3f7b2c67915), (0xc67178f2e372532b),
    (0xca273eceea26619c), (0xd186b8c721c0c207),
    (0xeada7dd6cde0eb1e), (0xf57d4f7fee6ed178),
    (0x06f067aa72176fba), (0x0a637dc5a2c898a6),
    (0x113f9804bef90dae), (0x1b710b35131c471b),
    (0x28db77f523047d84), (0x32caab7b40c72493),
    (0x3c9ebe0a15c9bebc), (0x431d67c49c100d4c),
    (0x4cc5d4becb3e42b6), (0x597f299cfc657e2a),
    (0x5fcb6fab3ad6faec), (0x6c44198c4a475817)
};
word64 rotrFixed64(word64 x, word64 y)
{
    return (x >> y) | (x << (sizeof(y) * 8 - y));
}

int main(){
    const word64* K = K512;
    word64 T[8];
    T[0] = (0xcbbb9d5dc1059ed8);
    T[1] = (0x629a292a367cd507);
    T[2] = (0x9159015a3070dd17);
    T[3] = (0x152fecd8f70e5939);
    T[4] = (0x67332667ffc00b31);
    T[5] = (0x8eb44a8768581511);
    T[6] = (0xdb0c2e0d64f98fa7);
    T[7] = (0x47b5481dbefa4fa4);
    printf("Testing SHA384 calculations:\r\n");
        word64 A = T[0],
               B = T[1],
               C = T[2],
               D = T[3],
               E = T[4],
               F = T[5],
               G = T[6],
               H = T[7];
//Word is the test string “abc” formatted for hashing
        word64 Word[16];
        Word[0] = 0x6162638000000000;
        Word[1] = 0;
        Word[2] = 0;
        Word[3] = 0;
        Word[4] = 0;
        Word[5] = 0;
        Word[6] = 0;
        Word[7] = 0;
        Word[8] = 0;
        Word[9] = 0;
        Word[10] = 0;
        Word[11] = 0;
        Word[12] = 0;
        Word[13] = 0;
        Word[14] = 0;
        Word[15] = 0x18;
        word64 Ch,Maj,Sum0,Sum1;
        word64 Temp1, Temp2;
        printf("init\t%016llX\t%016llX\t%016llX\t%016llX\r\n",A,B,C,D);
        printf("\t%016llX\t%016llX\t%016llX\t%016llX\r\n",E,F,G,H);
        for(int Jay=0; Jay<80; Jay++) {
            Ch = ((E&F)^((~E)&G));
            Maj = ((A&B)^(A&C)^(B&C));
            Sum0 = (rotrFixed64(A,28)^rotrFixed64(A,34)^rotrFixed64(A,39));
            Sum1 = (rotrFixed64(E,14)^rotrFixed64(E,18)^rotrFixed64(E,41));
            if(Jay < 16) {
                Word[Jay] = Word[Jay]; //Initialize value
            } else {
                //Word[(Jay-2)&15]  Word[(Jay-15)&15]
                Word[Jay] = (rotrFixed64(Word[(Jay-2)&15],19)^rotrFixed64(Word[(Jay-2)&15],61)^(Word[(Jay-2)&15]>>7)\
                 + Word[(Jay-7)&15]\
                 + rotrFixed64(Word[(Jay-15)&15],1)^rotrFixed64(Word[(Jay-15)&15],8)^(Word[(Jay-15)&15]>>6)\
                 + Word[(Jay-16)&15]);
            }
            Temp1 = (H + Sum1 + Ch + K[Jay] + Word[Jay]);
            Temp2 = (Sum0 + Maj);
            H = G;
            G = F;
            F = E;
            E = (D + Temp1);
            D = C;
            C = B;
            B = A;
            A = (Temp1 + Temp2);
            printf("t = %d\t%016llX\t%016llX\t%016llX\t%016llX\r\n",Jay,A,B,C,D);
            printf("\t%016llX\t%016llX\t%016llX\t%016llX\r\n",E,F,G,H);
        }
}

5

(36 replies, posted in wolfSSL)

I ran some test code:

        word64 test;
    
        test = 1;
        printf("test = %lu\n", test);
        printf("test = %llX\n",test);
        test = rotlFixed64(test, 33);
        printf("test = %lX\n", test);
        printf("test = %llX\n",test);
    
        test = 1;
        printf("test = %lu\n", test);
        printf("test = %llX\n",test);
        test = rotrFixed64(test, 5);
        printf("test = %lX\n", test);
        printf("test = %llX\n",test);

Here's the resulting printf's:

test = 3675008525
test = 1
test = A
test = 200000000
test = 10
test = 1
test = A
test = 800000000000000

From debugging printf values on the library before is how I found that %llX is the formatting to access the word64 variables, as I defined SIZEOF_LONG_LONG 8, which then defines the word64 variables as "unsigned long long"

#elif defined(SIZEOF_LONG_LONG) && SIZEOF_LONG_LONG == 8
    #define WORD64_AVAILABLE
    #define W64LIT(x) x##LL
    typedef unsigned long long word64;

6

(36 replies, posted in wolfSSL)

The first mismatch in calculations between what the values should be versus what they are is:
(On iteration 33: j=32, i=1):

What the mbed board spit out:
W[1]  =                                     00030000000000C0
h(1) from iteration 32                7973AADBDE294BE9
Calculated value to add to h(1)   CD3E67D18505477B
Calculated sum value:                46AF12AD632E92A4

What the sum value should be: 146b212ad632e9364
(Using online hex calculator)

Difference between the actual and expected hex values: 100030000000000c0

Note that the difference between what the board should have gotten and what it DID get, is equal to the value in W[1].
All of the values are equal until this iteration during the runtime code, although many of the W[] values are initialized to 0, so it could be that the algorithm properly calculates values when the initial value is 0, but when it is not, it screws up.

7

(36 replies, posted in wolfSSL)

Yes, trying with either USE_SLOW_SHA2 or CTAOCRYPT_SLOW_WORD64 turned on, the test will still fail.
I've had it set to CTAOCRYPT_SLOW_WORD64 for debugging the data values.

8

(36 replies, posted in wolfSSL)

All of the T[] array values get incorrectly set between the 32th and 48th iterations.
It seems weird that the values aren't incorrect in the first 32 iterations as well if there is something wrong with the hashing.
Checking all of the operations that the macro is performing by hand, they seem to compare perfectly with the Linux VM values, however, I am using word64 temp variables to hold the values with the printf() code I'm using. It seems unlikely that this would change any results however.

9

(36 replies, posted in wolfSSL)

It seems as if the hashing algorithm processes the first 32 blk2(i) operations correctly, but on the 33 it creates an incorrect result:

Iteration 33: blk2 92D4BFEAC8EE6CFB, array C93D547309EF4D2, Not the same
Iteration 34: blk2 FFFEDFFD9E05126B, array 152C73430238B6F8, Not the same
Iteration 35: blk2 75444F924D39F8CB, array 846A3B16EE426CA4, Not the same
Iteration 36: blk2 CBF727880F864734, array B6E512076FE85EFC, Not the same
Iteration 37: blk2 291AD7607119D8CE, array C4A989751CD5BDB0, Not the same
Iteration 38: blk2 634B4CB4052F9E01, array 2D6D5DF323C1D60A, Not the same
Iteration 39: blk2 38648D9AC374B0AD, array 1DECDCE0AB72FDC0, Not the same
Iteration 40: blk2 A1C61F12F1BC64F7, array EB78BB0BF025F958, Not the same
Iteration 41: blk2 8DFC2389BDA7B833, array 54C9385E9286C59A, Not the same
Iteration 42: blk2 82D8C2219F60AA25, array E609F1799268CBA0, Not the same
Iteration 43: blk2 848D4588E2C8173A, array 59513AFC0AF10668, Not the same
Iteration 44: blk2 8F9005DBFF894B94, array 36EF7435E3C554CA, Not the same
Iteration 45: blk2 1CDBC134F85B657B, array F7BF649F11283104, Not the same
Iteration 46: blk2 747B88619567CC8D, array 888F3D5A93C9ADFE, Not the same
Iteration 47: blk2 AD57F182EC429784, array 83DBDD9DDB8C0740, Not the same
Iteration 48: blk2 39B88CB240CD5D09, array A1A960E19BE75670, Not the same
Iteration 49: blk2 83F4490B8C668842, array F66D7A6A7F201430, Not the same
Iteration 50: blk2 C3372DF0694F503, array 61499E3C9AD4E0D6, Not the same
Iteration 51: blk2 59A5C7A11465DD87, array A40560DE31B821D8, Not the same
Iteration 52: blk2 143325BE752620DD, array 7C3C8EF1E2EF8E14, Not the same
Iteration 53: blk2 95F99D079519BC2D, array 5C4A464DFFAABD94, Not the same
Iteration 54: blk2 EC7CAC072605D68F, array F671E3C045B79DE2, Not the same
Iteration 55: blk2 9243E5CA611D604C, array 23666934B00CC330, Not the same
Iteration 56: blk2 E2CC15841B7D51A4, array C15C4D3665F4686A, Not the same
Iteration 57: blk2 CC01CF875B5E89F1, array C36BE3118E37B976, Not the same
Iteration 58: blk2 5D8DE3E4CA67B26B, array C07010F0F7CCEC5E, Not the same
Iteration 59: blk2 E5F6DF0D5F340C7D, array D31C4EC7C82C36EA, Not the same
Iteration 60: blk2 168877C71A6E7029, array 2728282B35B63110, Not the same
Iteration 61: blk2 4048D01FBC7AE37A, array 974606C2986C81EA, Not the same
Iteration 62: blk2 94D0C7C56086472C, array D02EDF4C93FCD196, Not the same
Iteration 63: blk2 255C9F7394695650, array 99A2097C99EFBA54, Not the same
Iteration 64: blk2 F98202F342EC0A78, array ECE272B4A6FB78C2, Not the same
Iteration 65: blk2 CA45E54894E33311, array B3D469AF78B00660, Not the same
Iteration 66: blk2 BB50C4B098AA5ADA, array 36D03F5076787E1C, Not the same
Iteration 67: blk2 921966AB72B1C0E1, array 80C9CC5C4E74AB3C, Not the same
Iteration 68: blk2 799EB278A124935F, array 937F1199535413AC, Not the same
Iteration 69: blk2 90D471B377BAE0A5, array 4F42780461FC927A, Not the same
Iteration 70: blk2 5909BA40AAFC44D7, array A4E4F8C1C101CAC4, Not the same
Iteration 71: blk2 8486A80E9EDDE4F5, array E7C9D38D7173E116, Not the same
Iteration 72: blk2 53A7096D05837E1D, array 90BF3ED4628C5066, Not the same
Iteration 73: blk2 76BFED3386CA1C3A, array 33E461FE597BCE1E, Not the same
Iteration 74: blk2 D297A901A881A25C, array E36961AA31B79D7A, Not the same
Iteration 75: blk2 5419F616CEF910B, array CE73FAE9BAE88DC4, Not the same
Iteration 76: blk2 E7B6F774BEA6FF32, array DCB6947C238C281A, Not the same
Iteration 77: blk2 8432BFCE9A7F37A8, array A21B34A570EAE97C, Not the same
Iteration 78: blk2 4BC73A806AEBE636, array 9A448FFF86625798, Not the same
Iteration 79: blk2 C780833B64180392, array C4A5823564365BAA, Not the same

(Array contains a table of the expected values based on the Linux VM output)

10

(36 replies, posted in wolfSSL)

Yes, you are right, I keep forgetting to modify the printf() to display the 64-bit values properly. When I went back and displayed it, it is showing the data prefixed to the first W[0] properly.

Yes, when I meant iteration 3, I meant that it had run through the 16 times processing twice, and was then on the third run through the 16 times loop. So, in that case, W[1] is actually the 34th "iteration" of the hash (2*16 + 2).

I agree with you on the table indices. I saw the bit masking on it, but still wanted to point it out as a possible cause.
And if no initializations are assumed, the variable declarations should be fine as well.

I am going to see if unrolling the bit operations (printing them) will show up any issues, but with how it runs fine through the first 32 operations just fine, it seems odd that it wouldn't screw up on the first iteration.

@Post 23 (Tangent): The mbed compiler does parallel compiling (I think), which might explain why the warnings show up whether they should or not. And they aren't consistent tbh, as sometimes the compiler will compile with no problems.

@32 vs 64 bit-ops: I'll be going through the bit operations and checking that the compiler runs the code as we would expect. All of the intermediate T[0] arrays contain the correct values when running on either platform (at least, up until the first W[1] is wrong)

11

(36 replies, posted in wolfSSL)

John,
The Httpbin.org Certs chain worked successfully (on Linux) setting FP_MAX_BITS=8192. (Returned 404 response from server)
It could be that the hash macros are being interpreted slightly different between the linux and mbed compilers?
It also might be possible that the linux compiler does something, like initializing a variable automatically, while the mbed compiler just leaves it as NULL? (Although, pretty unlikely as the compilers check pretty thoroughly for referencing uninitialized variables)
Lastly, there could be an issue with the array indexing that is causing the mbed compiler to reference a table outside of where the table was specified? (Also unlikely, as the compilers check for bounds errors too)

12

(36 replies, posted in wolfSSL)

Iteration 3: W[1] is the first different word during the hashing;
h(i) changes by 2-6 bits to cause it to change the W[1] value, which cascades to more wrong numbers later.
h(i) outputs: 9CB641F2CED773F3 (On the MBED board)
                  : 9CB941F2CED774B3 (On the LINUX VM)

13

(36 replies, posted in wolfSSL)

Looking at the W[16] array used for the hashing, it seems as though the "abc" string isn't input into the array for processing into the final hash.

W[0] [00000000]
W[1] [00000000]
W[2] [00000000]
W[3] [00000000]
W[4] [00000000]
W[5] [00000000]
W[6] [00000000]
W[7] [00000000]
W[8] [00000000]
W[9] [00000000]
W[10] [00000000]
W[11] [00000000]
W[12] [00000000]
W[13] [00000000]
W[14] [00000000]
W[15] [00000018]

Comparing it with this (http://m.metamorphosite.com/show-steps? … ;input=abc) example of SHA384 Hashing I found, it seems as though the "abc" string needs to be prefixed to the Word array before processing the algorithm. This would explain why all of the digest values are off as well.

14

(36 replies, posted in wolfSSL)

Here is a printout of all of the comiler warnings that appear:

Warning: Function "rotrFixed" was declared but never referenced in "mtsas-dev/MTS-Socket-dev/HTTPClient-SSL/CyaSSL/ctaocrypt/src/misc.c", Line: 70, Col: 26
Warning: Function "ByteReverseWords" was declared but never referenced in "mtsas-dev/MTS-Socket-dev/HTTPClient-SSL/CyaSSL/ctaocrypt/src/misc.c", Line: 97, Col: 20
Warning: Function "rotlFixed64" was declared but never referenced in "mtsas-dev/MTS-Socket-dev/HTTPClient-SSL/CyaSSL/ctaocrypt/src/misc.c", Line: 111, Col: 22
Warning: Function "rotrFixed64" was declared but never referenced in "mtsas-dev/MTS-Socket-dev/HTTPClient-SSL/CyaSSL/ctaocrypt/src/misc.c", Line: 117, Col: 22
Warning: Function "ByteReverseWords64" was declared but never referenced in "mtsas-dev/MTS-Socket-dev/HTTPClient-SSL/CyaSSL/ctaocrypt/src/misc.c", Line: 138, Col: 20
Warning: Function "xorbuf" was declared but never referenced in "mtsas-dev/MTS-Socket-dev/HTTPClient-SSL/CyaSSL/ctaocrypt/src/misc.c", Line: 159, Col: 20
Warning: Assignment in condition in "mtsas-dev/MTS-Socket-dev/HTTPClient-SSL/CyaSSL/src/internal.c", Line: 10155, Col: 14
Warning: Assignment in condition in "mtsas-dev/MTS-Socket-dev/HTTPClient-SSL/CyaSSL/src/internal.c", Line: 10156, Col: 14
Warning: Assignment in condition in "mtsas-dev/MTS-Socket-dev/HTTPClient-SSL/CyaSSL/src/internal.c", Line: 10157, Col: 14
Warning: Assignment in condition in "mtsas-dev/MTS-Socket-dev/HTTPClient-SSL/CyaSSL/src/internal.c", Line: 10158, Col: 14
Warning: Assignment in condition in "mtsas-dev/MTS-Socket-dev/HTTPClient-SSL/CyaSSL/src/internal.c", Line: 10173, Col: 14
Warning: Assignment in condition in "mtsas-dev/MTS-Socket-dev/HTTPClient-SSL/CyaSSL/src/internal.c", Line: 10174, Col: 14
Warning: Assignment in condition in "mtsas-dev/MTS-Socket-dev/HTTPClient-SSL/CyaSSL/src/internal.c", Line: 10175, Col: 14
Warning: Assignment in condition in "mtsas-dev/MTS-Socket-dev/HTTPClient-SSL/CyaSSL/src/internal.c", Line: 10176, Col: 14
Warning: Assignment in condition in "mtsas-dev/MTS-Socket-dev/HTTPClient-SSL/CyaSSL/src/internal.c", Line: 11848, Col: 22
Warning: Assignment in condition in "mtsas-dev/MTS-Socket-dev/HTTPClient-SSL/CyaSSL/src/internal.c", Line: 11849, Col: 22
Warning: Assignment in condition in "mtsas-dev/MTS-Socket-dev/HTTPClient-SSL/CyaSSL/src/internal.c", Line: 11851, Col: 22
Warning: Assignment in condition in "mtsas-dev/MTS-Socket-dev/HTTPClient-SSL/CyaSSL/src/internal.c", Line: 11853, Col: 22
Warning: Assignment in condition in "mtsas-dev/MTS-Socket-dev/HTTPClient-SSL/CyaSSL/src/internal.c", Line: 11870, Col: 22
Warning: Assignment in condition in "mtsas-dev/MTS-Socket-dev/HTTPClient-SSL/CyaSSL/src/internal.c", Line: 11871, Col: 22
Warning: Assignment in condition in "mtsas-dev/MTS-Socket-dev/HTTPClient-SSL/CyaSSL/src/internal.c", Line: 11873, Col: 22
Warning: Assignment in condition in "mtsas-dev/MTS-Socket-dev/HTTPClient-SSL/CyaSSL/src/internal.c", Line: 11875, Col: 22
Warning: Function "printf" declared implicitly in "mtsas-dev/MTS-Socket-dev/HTTPClient-SSL/CyaSSL/ctaocrypt/src/sha512.c", Line: 405, Col: 5

Comparing the sha384 digest between the board and the linux build, the initialize functions are called on both, but on the first Transform384() operation, the Linux code gets a different digest than the mbed version.
Something with the actual digest function must be different.

Here's the code I put to print out the debug data at the end of Transform384():

    for(int i=0; i<8; i++)
    printf("digest %d %llX\r\n", i, sha384->digest[i]); //REMOVE
    
    return 0;

The code to print the digests at the end of the Sha384Update():

    //REMOVE FROM
    static int x=0;
    for(int i=0; i<(SHA512_DIGEST_SIZE / sizeof(word64)); i++) {
        printf("digest(0)\t%llX\n",sha384->digest[i]); //REMOVE
    } x++;
    //REMOVE TO
    return 0;

The printouts for the actual digest data returned:

Mbed Nucleo Board:
digest(0)       CBBB9D5DC1059ED8
digest(0)       629A292A367CD507
digest(0)       9159015A3070DD17
digest(0)       152FECD8F70E5939
digest(0)       67332667FFC00B31
digest(0)       8EB44A8768581511
digest(0)       DB0C2E0D64F98FA7
digest(0)       47B5481DBEFA4FA4
digest 0 56CC791D50F2F90C
digest 1 8FDAC0B0F23E6737
digest 2 53958300BB3D074D
digest 3 A2A9CC5E6FCA408
digest 4 2C2F120FE7D49735
digest 5 FFBA3DDCABD47582
digest 6 FA79EF93D2258E9A
digest 7 68C05211D2BC1F91
LINUX:
InitSha384 Called
digest(0)    CBBB9D5DC1059ED8
digest(0)    629A292A367CD507
digest(0)    9159015A3070DD17
digest(0)    152FECD8F70E5939
digest(0)    67332667FFC00B31
digest(0)    8EB44A8768581511
digest(0)    DB0C2E0D64F98FA7
digest(0)    47B5481DBEFA4FA4
InitSha384 Called
digest(0)    CBBB9D5DC1059ED8
digest(0)    629A292A367CD507
digest(0)    9159015A3070DD17
digest(0)    152FECD8F70E5939
digest(0)    67332667FFC00B31
digest(0)    8EB44A8768581511
digest(0)    DB0C2E0D64F98FA7
digest(0)    47B5481DBEFA4FA4
digest 0 23FCDB853C1B60CB
digest 1 BC2332F642B7A150
digest 2 A39326D7E9F38FB7
digest 3 DBBBCFBBB544C85C
digest 4 F5983FEBD1710751
digest 5 566BFD073BE1C356
digest 6 A07A863D879EDD50
digest 7 B56481C7230EB91D

15

(36 replies, posted in wolfSSL)

Downloaded the 3.3.0 (Latest version) from your site, yes.
I ported the source files over to mbed and set it up similar to your example library for version 3.0.0 that was on mbed.
I'm using the online compiler for mbed.org and, as far as it shows, there are no compiler errors.
There are some warnings about assignments inside logic structures, such as

if(x = 5 == y){...}

, but no errors or anything beyond that.

Will get back to you on:

#define CTAOCRYPT_SLOW_WORD64
#define FAST_MATH
#define FP_MAX_BITS 8192
prints() at the end of the Sha384Update()

16

(36 replies, posted in wolfSSL)

Using Openssl with the same cert.pem file on https://httpbin.org, I'm able to connect and get a HTTP 200 response.
The server sends the first 3 certificates on client request, so only the AddTrustExternalRootCA file is required for an SSL connection using OpenSSL.

17

(36 replies, posted in wolfSSL)

If I remove the Sha384, then the Sha512 fails immediately afterwards with the same -10 error.

Note: If I remove the SHA512 ans SHA384 includes then the tests run through just fine. I would guess it is an issue with the SHA512 code that is cross-used by the SHA384 code, causing both to fail.

The device is Little-Endian (I tried with both Big-Endian and Little-Endian declared for various test runs, and only the Little-Endian works, not to mention I know from the board specs that it is Little-Endian)

As for the signer error, I went back and messed around with the cert ordering when concatenating, and was still getting the 155 error.
Note: I don't have access to the server itself, it's merely a public server we use to test HTTP access on. So if the issue is with their server-side certificate setup, then there's not much we can do to fix it.

18

(36 replies, posted in wolfSSL)

I went back to the linux client and concatenated the pem files like you suggested, and it ran into the ASN 155 error, but that might be expected as the httpbin.org server has a certificate which expires before the server cert.
The test code still fails on the error -10.
Are there specific locations in the test code which I can print/test to make sure each step is being completed properly?
I did print out the hash and expected hash values to compare the values, but they look completely unrelated:

Hash  vs  test output
56      CB
CC      0
79      75
1D      3F
50      45
F2      A3
F9      5E
C       8B
8F      B5
DA      A0
C0      3D
B0      69
F2      9A
3E      C6
67      50
37      7
53      27
95      2C
83      32
0       AB
BB      E
3D      DE
7       D1
4D      63
A       1A
2A      8B
9C      60
C5      5A
E6      43
FC      FF
A4      5B
8       ED
2C      80
2F      86
12      7
F       2B
E7      A1
D4      E7
97      CC
35      23
FF      58
BA      BA
3D      EC
DC      A1
AB      34
D4      C8
75      25
82      A7

Note: The output mismatch from post 7 was due to a printf() formatting I missed, and is not relevant for the issues at hand.

19

(36 replies, posted in wolfSSL)

The nucleo platform is 32-bit I believe.
The 64-bit "unsigned long long" variable is available.
sizeof(long long) returns 8.

Yep. Had commented out the #define NO_SHA512 line from the MBED settings and added the other defines.

#ifdef MBED
    #define USER_TIME
    #define DEBUG_CYASSL
    #define SIZEOF_LONG 4
    #define SIZEOF_LONG_LONG 8
    #define MAX_CHAIN_DEPTH 15
    #define NO_TIME_VERIFY //Define to disable certificate date verification
    #define CYASSL_USER_IO
    #define NO_FILESYSTEM
    #define NO_CERT
    #define USE_CERT_BUFFERS_1024
    #define NO_WRITEV
    #define NO_DEV_RANDOM
    #define CYASSL_SHA384
    #define CYASSL_SHA512
    //#define NO_SHA512
    #define NO_DH
    #define NO_DSA
    #define NO_HC128
    #define HAVE_ECC
    #define NO_SESSION_CACHE
    #define SINGLE_THREADED
    //#define CYASSL_CMSIS_RTOS
#endif

The #define NO_TIME_VERIFY is code we put in to remove the date checking on certificates, as the websites we needed to connect to contained outdated certs.

20

(36 replies, posted in wolfSSL)

Digging into the InitSha384 function call, it looks like th W64LIT() write operation is writing a 16 Hex to an 8 Hex memory space:
What it shows:

digest[0] [C1059ED8]
digest[1] [367CD507]
digest[2] [3070DD17]
digest[3] [F70E5939]
digest[4] [FFC00B31]
digest[5] [68581511]
digest[6] [64F98FA7]
digest[7] [BEFA4FA4]

What it should show:

digest[0] [cbbb9d5dc1059ed8]
digest[1] [629a292a367cd507]
digest[2] [9159015a3070dd17]
digest[3] [152fecd8f70e5939]
digest[4] [67332667ffc00b31]
digest[5] [8eb44a8768581511]
digest[6] [db0c2e0d64f98fa7]
digest[7] [47b5481dbefa4fa4]

21

(36 replies, posted in wolfSSL)

Looking more at the test SHA384 code, it looks like it is failing to get the correct memcmp() value returned.

if (memcmp(hash, test_sha[i].output, SHA384_DIGEST_SIZE) != 0)
            return -10 - i;

Checking the values of things:

SHA384_DIGEST_SIZE = 48

After InitSha384(&sha):
hash: 20017E30
test_sha[0].output 0

After Sha384Update(&sha,...):
hash: 20017E30
test_sha[0].output 801A4D4

After Sha384Final(&sha, hash):
hash: 20017E30
test_sha[0].output 801A4D4

22

(36 replies, posted in wolfSSL)

In answer to you first question:
I tried connecting to the server (httpbin.org) using the example client using the AddTrustExternalRootCA.pem, but was unable to get it to connect; kept returning error 188 - ASN no signer error to confirm failure
I think it needs the SHA384 to be added, but I'm a little confused on which file/where to enable the SHA384 usage?
Here's what I did to run the client:

./configure --enable-sha384 --enable-sha512
sudo make install
./testsuite/testsuite.test

It then displayed that the SHA256,SHA384,SHA512 had all three passed.
Then when running:

./examples/client/client -h httpbin.org -p 443 -A AddTrustCert -A ComodorRSACertAuth -A ComodorRSADomainValidSecureServerCA -g

Which then returns the -188 ASN signer error.
I would think using 3 of the 4 certificates offered by the server (discluding the servver cert itself) would work. Not sure why it's saying I have the wrong certificates.

In answer to your second question:
Code from running the main() in ctaocrypt/test.c

Found main
MD5      test passed!
MD4      test passed!
SHA      test passed!
SHA-256  test passed!
SHA-384  test failed!
 error = -10

Thus, it appears the SHA-384 code is failing on the mbed board?
I might be missing various defines that could be necessary, but I defined SIZEOF_LONG as well as SIZEOF_LONG_LONG.
I defined the SHA384 and SHA512 (which seem inter-correlated).

23

(36 replies, posted in wolfSSL)

After much head-smashing I was able to get the compiler to work. It turns out there are two different #defines of:
SIZEOF_LONG
SIZE_OF_LONG
SIZEOF_LONG_LONG
SIZE_OF_LONG_LONG
Enabling both "#define CYASSL_SHA384" and "#define CYASSL_SHA512" the connection with httpbin.org using SHA384 certificates fails on verifying the signature:

About to verify certificate signature
SigOID 656
Rsa SSL verify match encode error
Confirm signature failed
Failed to verify CA from chain

It seems as if the encoding verify fails when checking the certificates from the server. Returning error 155: "ASN sig error, confirm failure"
Trying to remove the intermediate certificates to not be individually verified (loading only the root certificate in the chain), it then fails on error 188 (No CA signer to verify with ASN_NO_SIGNER_E) for not having the intermediate certificates (though the server sends all 4 certificates in the verification chain)

24

(36 replies, posted in wolfSSL)

Working on implementing the SHA384 hash function for mbed, I've been having trouble getting the compiler to build.
I define "#define CYASSL_SHA384" under <root CyaSSL dir>/cyassl/ctaocrypt/settings.h
But after doing so, the compiler proceeds to complain that:

Error: Identifier "SHA384_DIGEST_SIZE" is undefined in "mtsas/MTS-Socket/HTTPClient-SSL/CyaSSL/cyassl/ctaocrypt/hmac.h", Line: 96, Col: 23
Error: Identifier "SHA384_BLOCK_SIZE" is undefined in "mtsas/MTS-Socket/HTTPClient-SSL/CyaSSL/cyassl/ctaocrypt/hmac.h", Line: 97, Col: 23
Error: Identifier "Sha384" is undefined in "mtsas/MTS-Socket/HTTPClient-SSL/CyaSSL/cyassl/ctaocrypt/hmac.h", Line: 125, Col: 9
Error: Identifier "SHA384" is undefined in "mtsas/MTS-Socket/HTTPClient-SSL/CyaSSL/ctaocrypt/src/asn.c", Line: 2934, Col: 14

It seems as if the various files contain all of the code to implement the SHA384 hashing, but the compiler isn't linking them properly>
Is it required to have the SHA512 enabled?
The reason for wanting to use the SHA384 is due to https://httpbin.org's using SHA384 for some of their certificates it seems.

25

(21 replies, posted in wolfSSL)

Yes, you are right. When I said "remote host" I merely meant that the socket connection through the modem was being disconnected from timing out.
Good to know that the handshake code is time-independent on wolfSSL's side. smile
You're right, there wasn't a cert. request from the server.
Ok, so using a socket timeout on the hardware-side is alright then.