1 ////////////////////////////////////////////////////////////////////////
2 //
3 // Copyright (C) 2016-2021 The Octave Project Developers
4 //
5 // See the file COPYRIGHT.md in the top-level directory of this
6 // distribution or <https://octave.org/copyright/>.
7 //
8 // This file is part of Octave.
9 //
10 // Octave is free software: you can redistribute it and/or modify it
11 // under the terms of the GNU General Public License as published by
12 // the Free Software Foundation, either version 3 of the License, or
13 // (at your option) any later version.
14 //
15 // Octave is distributed in the hope that it will be useful, but
16 // WITHOUT ANY WARRANTY; without even the implied warranty of
17 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18 // GNU General Public License for more details.
19 //
20 // You should have received a copy of the GNU General Public License
21 // along with Octave; see the file COPYING.  If not, see
22 // <https://www.gnu.org/licenses/>.
23 //
24 ////////////////////////////////////////////////////////////////////////
25 
26 // The hash functions are provided by gnulib.  We don't include gnulib
27 // headers directly in Octave's C++ source files to avoid problems that
28 // may be caused by the way that gnulib overrides standard library
29 // functions.
30 
31 #if defined (HAVE_CONFIG_H)
32 #  include "config.h"
33 #endif
34 
35 #include "md2.h"
36 #include "md4.h"
37 #include "md5.h"
38 #include "sha1.h"
39 #include "sha256.h"
40 #include "sha512.h"
41 
42 #include "hash-wrappers.h"
43 
octave_md2_digest_size(void)44 int octave_md2_digest_size (void) { return MD2_DIGEST_SIZE; }
octave_md4_digest_size(void)45 int octave_md4_digest_size (void) { return MD4_DIGEST_SIZE; }
octave_md5_digest_size(void)46 int octave_md5_digest_size (void) { return MD5_DIGEST_SIZE; }
octave_sha1_digest_size(void)47 int octave_sha1_digest_size (void) { return SHA1_DIGEST_SIZE; }
octave_sha224_digest_size(void)48 int octave_sha224_digest_size (void) { return SHA224_DIGEST_SIZE; }
octave_sha256_digest_size(void)49 int octave_sha256_digest_size (void) { return SHA256_DIGEST_SIZE; }
octave_sha384_digest_size(void)50 int octave_sha384_digest_size (void) { return SHA384_DIGEST_SIZE; }
octave_sha512_digest_size(void)51 int octave_sha512_digest_size (void) { return SHA512_DIGEST_SIZE; }
52 
53 void *
octave_md2_buffer_wrapper(const char * buf,size_t len,void * res)54 octave_md2_buffer_wrapper (const char *buf, size_t len, void *res)
55 {
56   return md2_buffer (buf, len, res);
57 }
58 
59 void *
octave_md4_buffer_wrapper(const char * buf,size_t len,void * res)60 octave_md4_buffer_wrapper (const char *buf, size_t len, void *res)
61 {
62   return md4_buffer (buf, len, res);
63 }
64 
65 void *
octave_md5_buffer_wrapper(const char * buf,size_t len,void * res)66 octave_md5_buffer_wrapper (const char *buf, size_t len, void *res)
67 {
68   return md5_buffer (buf, len, res);
69 }
70 
71 void *
octave_sha1_buffer_wrapper(const char * buf,size_t len,void * res)72 octave_sha1_buffer_wrapper (const char *buf, size_t len, void *res)
73 {
74   return sha1_buffer (buf, len, res);
75 }
76 
77 void *
octave_sha224_buffer_wrapper(const char * buf,size_t len,void * res)78 octave_sha224_buffer_wrapper (const char *buf, size_t len, void *res)
79 {
80   return sha224_buffer (buf, len, res);
81 }
82 
83 void *
octave_sha256_buffer_wrapper(const char * buf,size_t len,void * res)84 octave_sha256_buffer_wrapper (const char *buf, size_t len, void *res)
85 {
86   return sha256_buffer (buf, len, res);
87 }
88 
89 void *
octave_sha384_buffer_wrapper(const char * buf,size_t len,void * res)90 octave_sha384_buffer_wrapper (const char *buf, size_t len, void *res)
91 {
92   return sha384_buffer (buf, len, res);
93 }
94 
95 void *
octave_sha512_buffer_wrapper(const char * buf,size_t len,void * res)96 octave_sha512_buffer_wrapper (const char *buf, size_t len, void *res)
97 {
98   return sha512_buffer (buf, len, res);
99 }
100