Loading...
Searching...
No Matches
aguard_crypt.h File Reference

aguard_crypt.h - 01 Nov 2024 - aotto1968 More...

#include "key.h"
+ Include dependency graph for aguard_crypt.h:
+ This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Macros

#define IDENT   "aguard"
 

Functions

static void guard_crypt (register MK_BINN data, MK_SIZE size, bool const flag)
 
static void FilterHelp (const char *base)
 
static enum MkErrorE FilterArgs (MK_RT_ARGS MQ_CTX mqctx, MK_BFL args)
 

Variables

MK_NUM selKey = 1
 

Detailed Description

aguard_crypt.h - 01 Nov 2024 - aotto1968

Version
8dbe2fd9f53d3983fa80dd80ddcb8f254b666391
Date
Fri Nov 1 22:34:52 2024 +0100
Author
aotto1968 aotto.nosp@m.1968.nosp@m.@t-on.nosp@m.line.nosp@m..de

Definition in file aguard_crypt.h.

Macro Definition Documentation

◆ IDENT

#define IDENT   "aguard"

Definition at line 19 of file aguard_crypt.h.

Function Documentation

◆ FilterArgs()

static enum MkErrorE FilterArgs ( MK_RT_ARGS MQ_CTX mqctx,
MK_BFL args )
static

Definition at line 64 of file aguard_crypt.h.

65{
66 bool printDIG = false;
67
68 MkBufferListCheckOptionO_3E(args, "-d", &printDIG);
69 MkBufferListCheckOptionO_3E(args, "--dig", &printDIG);
70
71 if (printDIG == true) {
72 fprintf(stderr,"\n");
73 fprintf(stderr,"'%s' key information..\n", MqConfigGetName(mqctx));
74 fprintf(stderr,"\n");
75 fprintf(stderr," sign-dat: %s\n", DIG_DATE);
76 fprintf(stderr," sign-dig: %s\n", DIG_DATA);
77 fprintf(stderr," sign-min: %i byte\n", KEY_MIN);
78 fprintf(stderr," sign-num: %i\n", KEY_NUM);
79 fprintf(stderr,"\n");
80
81 return MK_CONTINUE;
82 }
83
85 MkBufferListCheckOptionI_3E(args, "--key", &selKey);
86
88 return MkErrorSetV_1E("key-error: invalid value for argument '-k,--key', '%i' have to be: '0 <= NUM <= %i'",
90 }
91
92 return MK_OK;
93error:
94 return MK_ERROR;
95}
MK_NUM selKey
#define MkBufferListCheckOptionO_3E(bfl, opt, val_out)
#define MkBufferListCheckOptionI_3E(bfl, opt, val_out)
#define MkErrorSetV_1E(printfmt,...)
MK_ERROR
MK_CONTINUE
MK_OK
static MK_STRN MqConfigGetName(MQ_CTXN const ctx)
MK_NUM KEY_MIN
Definition key.h:92
MK_NUM KEY_NUM
Definition key.h:91
MK_STRN DIG_DATA
Definition key.h:95
MK_STRN DIG_DATE
Definition key.h:94
+ Here is the caller graph for this function:

◆ FilterHelp()

static void FilterHelp ( const char * base)
static

Definition at line 39 of file aguard_crypt.h.

40{
41 fputs("\n", stderr);
42 fprintf(stderr, "usage: %s [OPTION]... [ARGUMENT]...\n", base);
43 fputs("\n", stderr);
44 fputs(" This tool is the data protection filter of NHI1.\n", stderr);
45 fputs("\n", stderr);
46 fprintf(stderr, " %s [ARGUMENT]... syntax:\n", base);
47 fprintf(stderr, " aclient... %c %s --key NUM ... [encrypted] ... %c %s --key NUM... %c aserver\n",
48 MK_ALFA, base, MK_ALFA, base, MK_ALFA);
49 fputs("\n", stderr);
50 fputs(MqHelp (NULL), stderr);
51 fputs("\n", stderr);
52 fprintf(stderr, " %s [OPTION]:\n", base);
53 fputs( " -h, --help print this help\n", stderr);
54 fputs( " -d, --dig print the key diggest\n", stderr);
55 fprintf(stderr, " -k, --key NUM select the KEY for encryption...(0 <= NUM <= %i)\n", KEY_NUM);
56 fputs( " 0 = NO\n", stderr);
57 fputs( " 1 = DEFAULT\n", stderr);
58 fputs("\n", stderr);
59
60 exit(EXIT_SUCCESS);
61}
#define MK_ALFA
MK_STR MqHelp(MK_STRN tool)
+ Here is the caller graph for this function:

◆ guard_crypt()

static void guard_crypt ( register MK_BINN data,
MK_SIZE size,
bool const flag )
static

Definition at line 21 of file aguard_crypt.h.

21 {
22 if (selKey == 0) return;
23 register MK_BINN key = KEY_REF[selKey];
24 const MK_BINN keyend = KEY_REF[selKey]+KEY_LEN[selKey];
25 const MK_BINN dataend = data+size;
26 for (;data<dataend; data++,key++) {
27 if (key >= keyend) {
28 key=KEY_REF[selKey];
29 }
30 if (flag) {
31 *(MK_BIN)data += *key;
32 } else {
33 *(MK_BIN)data -= *key;
34 }
35 }
36}
MK_BINB * MK_BIN
MK_BINB const * MK_BINN
MK_NUM KEY_LEN[]
Definition key.h:84
MK_BIN KEY_REF[]
Definition key.h:87
+ Here is the caller graph for this function:

Variable Documentation

◆ selKey

MK_NUM selKey = 1

Definition at line 18 of file aguard_crypt.h.