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));
}