"Fossies" - the Fresh Open Source Software Archive

Member "tin-2.4.2/libcanlock/include/canlock.h" (28 Jun 2017, 4064 Bytes) of package /linux/misc/tin-2.4.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 and the latest Fossies "Diffs" side-by-side code changes report: 2.4.1_vs_2.4.2.

    1 /*
    2  * COPYRIGHT AND PERMISSION NOTICE
    3  *
    4  * Copyright (c) 2017 Dennis Preiser
    5  * Copyright (c) 2017 Michael Baeuerle
    6  * Copyright (c) 2003 G.J. Andruk
    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 /* Constants */
   42 
   43 /* libcanlock API major version */
   44 #define CL_API_MAJOR  3
   45 
   46 /* libcanlock API minor version */
   47 #define CL_API_MINOR  0
   48 
   49 /* libcanlock legacy API V2 emulation available if nonzero */
   50 #define CL_API_V2  1
   51 
   52 /* Supported hash algorithms for <scheme> according to RFCxxxx */
   53 #define CL_INVALID  0
   54 #define CL_SHA1     1         /* IANA registered name: "sha1" */
   55 #define CL_SHA224   2         /* IANA registered name: "sha224" */
   56 #define CL_SHA256   3         /* IANA registered name: "sha256" */
   57 #define CL_SHA384   4         /* IANA registered name: "sha384" */
   58 #define CL_SHA512   5         /* IANA registered name: "sha512" */
   59 
   60 
   61 /* ========================================================================== */
   62 /* Type definitions  */
   63 
   64 typedef int cl_hash_version;
   65 
   66 
   67 /* ========================================================================== */
   68 /* New API (available since version 3.0.0) */
   69 
   70 extern char *cl_get_key(cl_hash_version which_hash,
   71                         const unsigned char *secret, size_t seclen,
   72                         const unsigned char *message, size_t msglen);
   73 extern char *cl_get_lock(cl_hash_version which_hash,
   74                          const unsigned char *secret, size_t seclen,
   75                          const unsigned char *message, size_t msglen);
   76 extern int cl_split(char *input, char **klstring);
   77 extern int cl_verify(cl_hash_version which_hash,
   78                      const char *key, const char *lock);
   79 extern int cl_clear_secret(void *sec, size_t sec_size, size_t buf_size);
   80 
   81 
   82 #if CL_API_V2
   83 /* ========================================================================== */
   84 /* Old API (Version 2b emulation) provided for backward compatibility */
   85 
   86 extern char *lock_strip_alpha(char *key, char *type);
   87 extern char *lock_strip(char *key, char *type);
   88 
   89 /* Wrappers around new cl_(get_key|get_lock|verify) with hash set to SHA1 */
   90 extern char *sha_key(const unsigned char *secret, size_t seclen,
   91                      const unsigned char *message, size_t msglen);
   92 extern char *sha_lock(const unsigned char *secret, size_t seclen,
   93                       const unsigned char *message, size_t msglen);
   94 extern int sha_verify(const char *key, const char *lock);
   95 #endif  /* CL_API_V2 */
   96 
   97 
   98 #endif  /* _CANLOCK_H */
   99 
  100 /* EOF */