From 6a21bf979c5ef4ad473971257f59fe9101397cd6 Mon Sep 17 00:00:00 2001 From: Mat Date: Wed, 8 Apr 2020 00:23:54 +0300 Subject: Initial resource pack support (#4622) --- src/mbedTLS++/Sha1Checksum.cpp | 14 ++++++++++++++ src/mbedTLS++/Sha1Checksum.h | 5 ++++- 2 files changed, 18 insertions(+), 1 deletion(-) (limited to 'src/mbedTLS++') diff --git a/src/mbedTLS++/Sha1Checksum.cpp b/src/mbedTLS++/Sha1Checksum.cpp index f55df025a..8ed7976ae 100644 --- a/src/mbedTLS++/Sha1Checksum.cpp +++ b/src/mbedTLS++/Sha1Checksum.cpp @@ -85,6 +85,20 @@ void cSha1Checksum::Finalize(cSha1Checksum::Checksum & a_Output) +void cSha1Checksum::DigestToHex(const Checksum & a_Digest, AString & a_Out) +{ + a_Out.clear(); + a_Out.reserve(40); + for (int i = 0; i < 20; i++) + { + AppendPrintf(a_Out, "%x", a_Digest[i]); + } +} + + + + + void cSha1Checksum::DigestToJava(const Checksum & a_Digest, AString & a_Out) { Checksum Digest; diff --git a/src/mbedTLS++/Sha1Checksum.h b/src/mbedTLS++/Sha1Checksum.h index f85f5e8b5..dbe7db567 100644 --- a/src/mbedTLS++/Sha1Checksum.h +++ b/src/mbedTLS++/Sha1Checksum.h @@ -32,10 +32,13 @@ public: /** Returns true if the object is accepts more input data, false if Finalize()-d (need to Restart()) */ bool DoesAcceptInput(void) const { return m_DoesAcceptInput; } + /** Converts a SHA1 digest into hex */ + static void DigestToHex(const Checksum & a_Digest, AString & a_Out); + /** Converts a raw 160-bit SHA1 digest into a Java Hex representation According to http://wiki.vg/Protocol_Encryption */ - static void DigestToJava(const Checksum & a_Digest, AString & a_JavaOut); + static void DigestToJava(const Checksum & a_Digest, AString & a_Out); /** Clears the current context and start a new checksum calculation */ void Restart(void); -- cgit v1.2.3