]> git.zerfleddert.de Git - proxmark3-svn/blobdiff - client/crypto/libpcrypto.c
EVM fixes and additions (RRG repository PRs 78-82 by @merlokk) (#776)
[proxmark3-svn] / client / crypto / libpcrypto.c
index 896048bf0e2f5562e7d1db1d3f584f4ad4811855..ebc1e987ba78eb19203a749bf22a858168e7fafd 100644 (file)
@@ -19,6 +19,7 @@
 #include <mbedtls/pk.h>
 #include <mbedtls/ecdsa.h>
 #include <mbedtls/sha256.h>
+#include <mbedtls/sha512.h>
 #include <mbedtls/ctr_drbg.h>
 #include <mbedtls/entropy.h>
 #include <mbedtls/error.h>
@@ -106,6 +107,20 @@ int sha256hash(uint8_t *input, int length, uint8_t *hash) {
        return 0;
 }
 
+int sha512hash(uint8_t *input, int length, uint8_t *hash) {
+       if (!hash || !input)
+               return 1;
+       
+       mbedtls_sha512_context sctx;
+       mbedtls_sha512_init(&sctx);
+       mbedtls_sha512_starts(&sctx, 0); //SHA-512, not 384
+       mbedtls_sha512_update(&sctx, input, length);
+       mbedtls_sha512_finish(&sctx, hash);     
+       mbedtls_sha512_free(&sctx);
+       
+       return 0;
+}
+
 int ecdsa_init_str(mbedtls_ecdsa_context *ctx, char * key_d, char *key_x, char *key_y) {
        if (!ctx)
                return 1;
Impressum, Datenschutz