1 /* 2 ** OSSP uuid - Universally Unique Identifier 3 ** Copyright (c) 2004-2008 Ralf S. Engelschall <rse@engelschall.com> 4 ** Copyright (c) 2004-2008 The OSSP Project <http://www.ossp.org/> 5 ** 6 ** This file is part of OSSP uuid, a library for the generation 7 ** of UUIDs which can found at http://www.ossp.org/pkg/lib/uuid/ 8 ** 9 ** Permission to use, copy, modify, and distribute this software for 10 ** any purpose with or without fee is hereby granted, provided that 11 ** the above copyright notice and this permission notice appear in all 12 ** copies. 13 ** 14 ** THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED 15 ** WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 16 ** MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 17 ** IN NO EVENT SHALL THE AUTHORS AND COPYRIGHT HOLDERS AND THEIR 18 ** CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 19 ** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 20 ** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF 21 ** USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 22 ** ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 23 ** OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT 24 ** OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 25 ** SUCH DAMAGE. 26 ** 27 ** uuid_sha1.h: SHA-1 API definition 28 */ 29 30 #ifndef __SHA1_H___ 31 #define __SHA1_H___ 32 33 #include <string.h> /* size_t */ 34 35 #define SHA1_PREFIX uuid_ 36 37 /* embedding support */ 38 #ifdef SHA1_PREFIX 39 #if defined(__STDC__) || defined(__cplusplus) 40 #define __SHA1_CONCAT(x,y) x ## y 41 #define SHA1_CONCAT(x,y) __SHA1_CONCAT(x,y) 42 #else 43 #define __SHA1_CONCAT(x) x 44 #define SHA1_CONCAT(x,y) __SHA1_CONCAT(x)y 45 #endif 46 #define sha1_st SHA1_CONCAT(SHA1_PREFIX,sha1_st) 47 #define sha1_t SHA1_CONCAT(SHA1_PREFIX,sha1_t) 48 #define sha1_create SHA1_CONCAT(SHA1_PREFIX,sha1_create) 49 #define sha1_init SHA1_CONCAT(SHA1_PREFIX,sha1_init) 50 #define sha1_update SHA1_CONCAT(SHA1_PREFIX,sha1_update) 51 #define sha1_store SHA1_CONCAT(SHA1_PREFIX,sha1_store) 52 #define sha1_format SHA1_CONCAT(SHA1_PREFIX,sha1_format) 53 #define sha1_destroy SHA1_CONCAT(SHA1_PREFIX,sha1_destroy) 54 #endif 55 56 struct sha1_st; 57 typedef struct sha1_st sha1_t; 58 59 #define SHA1_LEN_BIN 20 60 #define SHA1_LEN_STR 40 61 62 typedef enum { 63 SHA1_RC_OK = 0, 64 SHA1_RC_ARG = 1, 65 SHA1_RC_MEM = 2, 66 SHA1_RC_INT = 3 67 } sha1_rc_t; 68 69 extern sha1_rc_t sha1_create (sha1_t **sha1); 70 extern sha1_rc_t sha1_init (sha1_t *sha1); 71 extern sha1_rc_t sha1_update (sha1_t *sha1, const void *data_ptr, size_t data_len); 72 extern sha1_rc_t sha1_store (sha1_t *sha1, void **data_ptr, size_t *data_len); 73 extern sha1_rc_t sha1_format (sha1_t *sha1, char **data_ptr, size_t *data_len); 74 extern sha1_rc_t sha1_destroy (sha1_t *sha1); 75 76 #endif /* __SHA1_H___ */ 77 78