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

tag: nhi1-release-250425 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

tag: nhi1-release-250425

Definition in file aguard_crypt.h.

Macro Definition Documentation

◆ IDENT

#define IDENT   "aguard"

Definition at line 16 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 61 of file aguard_crypt.h.

62{
63 bool printDIG = false;
64
65 MkBufferListCheckOptionO_3E(args, "-d", &printDIG);
66 MkBufferListCheckOptionO_3E(args, "--dig", &printDIG);
67
68 if (printDIG == true) {
69 fprintf(stderr,"\n");
70 fprintf(stderr,"'%s' key information..\n", MqConfigGetName(mqctx));
71 fprintf(stderr,"\n");
72 fprintf(stderr," sign-dat: %s\n", DIG_DATE);
73 fprintf(stderr," sign-dig: %s\n", DIG_DATA);
74 fprintf(stderr," sign-min: %i byte\n", KEY_MIN);
75 fprintf(stderr," sign-num: %i\n", KEY_NUM);
76 fprintf(stderr,"\n");
77
78 return MK_CONTINUE;
79 }
80
82 MkBufferListCheckOptionI_3E(args, "--key", &selKey);
83
85 return MkErrorSetV_1E("key-error: invalid value for argument '-k,--key', '%i' have to be: '0 <= NUM <= %i'",
87 }
88
89 return MK_OK;
90error:
91 return MK_ERROR;
92}
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:108
MK_NUM KEY_NUM
Definition key.h:107
MK_STRN DIG_DATA
Definition key.h:111
MK_STRN DIG_DATE
Definition key.h:110
+ Here is the caller graph for this function:

◆ FilterHelp()

static void FilterHelp ( const char * base)
static

Definition at line 36 of file aguard_crypt.h.

37{
38 fputs("\n", stderr);
39 fprintf(stderr, "usage: %s [OPTION]... [ARGUMENT]...\n", base);
40 fputs("\n", stderr);
41 fputs(" This tool is the data protection filter of NHI1.\n", stderr);
42 fputs("\n", stderr);
43 fprintf(stderr, " %s [ARGUMENT]... syntax:\n", base);
44 fprintf(stderr, " aclient... %c %s --key NUM ... [encrypted] ... %c %s --key NUM... %c aserver\n",
45 MK_ALFA, base, MK_ALFA, base, MK_ALFA);
46 fputs("\n", stderr);
47 fputs(MqHelp (NULL), stderr);
48 fputs("\n", stderr);
49 fprintf(stderr, " %s [OPTION]:\n", base);
50 fputs( " -h, --help print this help\n", stderr);
51 fputs( " -d, --dig print the key diggest\n", stderr);
52 fprintf(stderr, " -k, --key NUM select the KEY for encryption...(0 <= NUM <= %i)\n", KEY_NUM);
53 fputs( " 0 = NO\n", stderr);
54 fputs( " 1 = DEFAULT\n", stderr);
55 fputs("\n", stderr);
56
57 exit(EXIT_SUCCESS);
58}
#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 18 of file aguard_crypt.h.

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

Variable Documentation

◆ selKey

MK_NUM selKey = 1

Definition at line 15 of file aguard_crypt.h.