tin  2.4.5
About: TIN is a threaded NNTP and spool based UseNet newsreader.
  Fossies Dox: tin-2.4.5.tar.xz  ("unofficial" and yet experimental doxygen-generated source code documentation)  

canlock.c File Reference
#include <config.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "canlock.h"
Include dependency graph for canlock.c:

Go to the source code of this file.

Macros

#define SEC_DATA_SIZE_MAX   (size_t) 1024
 

Functions

static void print_version (void)
 Print program version information. More...
 
static void print_help (void)
 Print help. More...
 
static cl_hash_version get_hash (const char *scheme)
 Check scheme for supported hash algorithm. More...
 
static unsigned char * get_secret (size_t *sec_size, size_t *buf_size)
 Read secret data from stdin. More...
 
static int exec_request (cl_hash_version hash, int quiet, const char *opt, const char *opt_value)
 Execute request. More...
 
int main (int argc, char **argv)
 CLI utility. More...
 

Macro Definition Documentation

◆ SEC_DATA_SIZE_MAX

#define SEC_DATA_SIZE_MAX   (size_t) 1024

Size of buffer for secret data

Definition at line 48 of file canlock.c.

Function Documentation

◆ exec_request()

static int exec_request ( cl_hash_version  hash,
int  quiet,
const char *  opt,
const char *  opt_value 
)
static

Execute request.

Parameters
[in]hashHash algorithm ID
[in]quietSuppress result on stdout for check operation
[in]optPointer to option string
[in]opt_valuePointer to option value string
Attention
The caller must ensure that opt and opt_val are not NULL .
Returns
  • 0 on success
  • -1 on error

Definition at line 197 of file canlock.c.

References cl_clear_secret(), cl_get_key(), cl_get_lock(), CL_INVALID, cl_split(), cl_verify(), get_secret(), and quiet.

Referenced by main().

◆ get_hash()

static cl_hash_version get_hash ( const char *  scheme)
static

Check scheme for supported hash algorithm.

Parameters
[in]schemeString with scheme in lowercase
Returns
  • Hash algorithm ID on success
  • CL_INVALID on error

Definition at line 111 of file canlock.c.

References CL_INVALID, CL_SHA1, CL_SHA224, CL_SHA256, CL_SHA384, and CL_SHA512.

Referenced by main().

◆ get_secret()

static unsigned char* get_secret ( size_t *  sec_size,
size_t *  buf_size 
)
static

Read secret data from stdin.

Parameters
[out]sec_sizePointer to size of secret data
[out]buf_sizePointer to size of buffer

Secret data is read until EOF. Hitting the buffer size limit SEC_DATA_SIZE_MAX is treated as an error.

Attention
The caller must not call free() for the returned pointer but should call cl_clear_secret() instead.
Returns
  • Pointer to secret data on success
  • NULL on error (nothing was written to secsize and bufsize )

Definition at line 148 of file canlock.c.

References buf, cl_clear_secret(), EOF, and SEC_DATA_SIZE_MAX.

Referenced by exec_request().

◆ main()

int main ( int  argc,
char **  argv 
)

CLI utility.

Parameters
[in]argcNumber of command line arguments
[in]argvArray containing command line argument strings
Returns
  • EXIT_SUCCESS on success
  • EXIT_FAILURE on error

Definition at line 349 of file canlock.c.

References ABORT, CL_INVALID, CL_SHA256, exec_request(), EXIT_FAILURE, EXIT_SUCCESS, get_hash(), print_help(), print_version(), and quiet.

◆ print_help()

static void print_help ( void  )
static

Print help.

Definition at line 68 of file canlock.c.

References PACKAGE_NAME.

Referenced by main().

◆ print_version()

static void print_version ( void  )
static

Print program version information.

Definition at line 54 of file canlock.c.

References PACKAGE_STRING.

Referenced by main().