"Fossies" - the Fresh Open Source Software Archive 
Member "tin-2.6.2/libcanlock/include/canlock.h" (23 Aug 2021, 4214 Bytes) of package /linux/misc/tin-2.6.2.tar.xz:
As a special service "Fossies" has tried to format the requested source page into HTML format using (guessed) C and C++ source code syntax highlighting (style:
standard) with prefixed line numbers and
code folding option.
Alternatively you can here
view or
download the uninterpreted source code file.
For more information about "canlock.h" see the
Fossies "Dox" file reference documentation.
1 /*
2 * COPYRIGHT AND PERMISSION NOTICE
3 *
4 * Copyright (c) 2003 G.J. Andruk
5 * Copyright (c) 2017 Dennis Preiser
6 * Copyright (c) 2018 Michael Baeuerle
7 *
8 * All rights reserved.
9 *
10 * Permission is hereby granted, free of charge, to any person obtaining
11 * a copy of this software and associated documentation files (the
12 * "Software"), to deal in the Software without restriction, including
13 * without limitation the rights to use, copy, modify, merge, publish,
14 * distribute, and/or sell copies of the Software, and to permit persons
15 * to whom the Software is furnished to do so, provided that the above
16 * copyright notice(s) and this permission notice appear in all copies of
17 * the Software and that both the above copyright notice(s) and this
18 * permission notice appear in supporting documentation.
19 *
20 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
21 * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
22 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT
23 * OF THIRD PARTY RIGHTS. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
24 * HOLDERS INCLUDED IN THIS NOTICE BE LIABLE FOR ANY CLAIM, OR ANY
25 * SPECIAL INDIRECT OR CONSEQUENTIAL DAMAGES, OR ANY DAMAGES WHATSOEVER
26 * RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF
27 * CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
28 * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
29 *
30 * Except as contained in this notice, the name of a copyright holder
31 * shall not be used in advertising or otherwise to promote the sale, use
32 * or other dealings in this Software without prior written authorization
33 * of the copyright holder.
34 */
35
36 #ifndef _CANLOCK_H
37 #define _CANLOCK_H
38
39
40 /* ========================================================================== */
41 /* Include header files */
42
43 #include <stddef.h> /* For size_t */
44
45
46 /* ========================================================================== */
47 /* Constants */
48
49 /* libcanlock API major version */
50 #define CL_API_MAJOR 3
51
52 /* libcanlock API minor version */
53 #define CL_API_MINOR 0
54
55 /* libcanlock legacy API V2 emulation available if nonzero */
56 #define CL_API_V2 1
57
58 /* Supported hash algorithms for <scheme> according to RFC 8315 */
59 #define CL_INVALID 0
60 #define CL_SHA1 1 /* IANA registered name: "sha1" */
61 #define CL_SHA224 2 /* IANA registered name: "sha224" */
62 #define CL_SHA256 3 /* IANA registered name: "sha256" */
63 #define CL_SHA384 4 /* IANA registered name: "sha384" */
64 #define CL_SHA512 5 /* IANA registered name: "sha512" */
65
66
67 /* ========================================================================== */
68 /* Type definitions */
69
70 typedef int cl_hash_version;
71
72
73 /* ========================================================================== */
74 /* New API (available since version 3.0.0) */
75
76 extern char *cl_get_key(cl_hash_version which_hash,
77 const unsigned char *secret, size_t seclen,
78 const unsigned char *message, size_t msglen);
79 extern char *cl_get_lock(cl_hash_version which_hash,
80 const unsigned char *secret, size_t seclen,
81 const unsigned char *message, size_t msglen);
82 extern int cl_split(char *input, char **klstring);
83 extern int cl_verify(cl_hash_version which_hash,
84 const char *key, const char *lock);
85 extern int cl_clear_secret(void *sec, size_t sec_size, size_t buf_size);
86
87
88 #if CL_API_V2
89 /* ========================================================================== */
90 /* Old API (Version 2b emulation) provided for backward compatibility */
91
92 extern char *lock_strip_alpha(char *key, char *type);
93 extern char *lock_strip(char *key, char *type);
94
95 /* Wrappers around new cl_(get_key|get_lock|verify) with hash set to SHA1 */
96 extern char *sha_key(const unsigned char *secret, size_t seclen,
97 const unsigned char *message, size_t msglen);
98 extern char *sha_lock(const unsigned char *secret, size_t seclen,
99 const unsigned char *message, size_t msglen);
100 extern int sha_verify(const char *key, const char *lock);
101 #endif /* CL_API_V2 */
102
103
104 #endif /* _CANLOCK_H */
105
106 /* EOF */