summaryrefslogtreecommitdiffstats
path: root/md5.h
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2023-06-16 11:13:28 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2023-06-16 11:13:28 +0000
commitbfe1c9e528f1db429020e40e15b2483d1ec32b75 (patch)
tree36aee5c76f09362bad7adc8d4163e902fae81a39 /md5.h
parentReleasing debian version 1.23-5. (diff)
downloadlziprecover-bfe1c9e528f1db429020e40e15b2483d1ec32b75.tar.xz
lziprecover-bfe1c9e528f1db429020e40e15b2483d1ec32b75.zip
Merging upstream version 1.24~pre1.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'md5.h')
-rw-r--r--md5.h20
1 files changed, 16 insertions, 4 deletions
diff --git a/md5.h b/md5.h
index fd84461..552a079 100644
--- a/md5.h
+++ b/md5.h
@@ -1,6 +1,6 @@
/* Functions to compute MD5 message digest of memory blocks according to the
definition of MD5 in RFC 1321 from April 1992.
- Copyright (C) 2020-2022 Antonio Diaz Diaz.
+ Copyright (C) 2020-2023 Antonio Diaz Diaz.
This library is free software. Redistribution and use in source and
binary forms, with or without modification, are permitted provided
@@ -18,6 +18,18 @@
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
*/
+struct md5_type
+ {
+ uint8_t data[16]; // 128-bit md5 digest
+
+ bool operator==( const md5_type & d ) const
+ { return ( std::memcmp( data, d.data, 16 ) == 0 ); }
+ bool operator!=( const md5_type & d ) const { return !( *this == d ); }
+// const uint8_t & operator[]( const int i ) const { return data[i]; }
+ uint8_t & operator[]( const int i ) { return data[i]; }
+ };
+
+
class MD5SUM
{
uint64_t count; // data length in bytes, modulo 2^64
@@ -39,11 +51,11 @@ public:
}
void md5_update( const uint8_t * const buffer, const unsigned long len );
- void md5_finish( uint8_t digest[16] );
+ void md5_finish( md5_type & digest );
};
void compute_md5( const uint8_t * const buffer, const unsigned long len,
- uint8_t digest[16] );
+ md5_type & digest );
bool check_md5( const uint8_t * const buffer, const unsigned long len,
- const uint8_t digest[16] );
+ const md5_type & digest );