From a424d17fa7a6fcfd90e4f6bd5a0d15d98440a59f Mon Sep 17 00:00:00 2001 From: Jeff Connelly Date: Wed, 14 May 2008 22:27:58 -0700 Subject: [PATCH] Initial commit - libotp with PAD and PACKAGE structures. --- .gitignore | 1 + Makefile | 8 +++++ libotp | Bin 0 -> 13204 bytes libotp.c | 102 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 4 files changed, 111 insertions(+) create mode 100644 .gitignore create mode 100644 Makefile create mode 100755 libotp create mode 100644 libotp.c diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..cb77d18 --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +*.dSYM diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..19a58cf --- /dev/null +++ b/Makefile @@ -0,0 +1,8 @@ +CC=gcc +CFLAGS=-g -Wall -pedantic +LDFLAGS=-g + +libotp: libotp.c + +.c: + $(CC) $(CFLAGS) $@.c $(LDFLAGS) -o $@ diff --git a/libotp b/libotp new file mode 100755 index 0000000000000000000000000000000000000000..5dd04afb62d957f5e1e38dc87e9e16cb2a144fd0 GIT binary patch literal 13204 zcwX&WU1%It6h7OmcByHzl{^Hs?SflvO}o>USVBQaVg?&))6gWfHI-p@W_GjN-I--( zHg2MY*rgB48blEk#3w}%3i>1k`%v3pE&X{ApG2XcLLe3Lu%HNbJ?GxLnTbi-*9!L| zXYM!We&^hC@6N*voZSBVk9!*dpbc#UT07chyg83!1g#fM(?~{=Nkl>m5( z#{1-;`riVI9XdL4?0B&IeZXr^z;gW?g&vqbUoMt3Ur!e-SSS8z;PH<_fEfJ(z<{o%F*R?=v z_W)mu|ArA}%k`jT4MX!%`%_q2F1==qvnpnE+VibqYG64?LPA19LPA19;-NtvYQI;1 zTdLlT*I$p;PA6gRXsq^1GFrVF`S#ZhksIiW)!V99qvtP||HPa2g&X*iSQ|{j!qDRY zjRi__via30z6{o9C-B<5!+rJHBkXP*7r5KSe5dMa>{=gtb)9=#p$NdVo9EtRT#eN> zEOxghYUtC)MVdN;|EPs~++h_J}PWOS~Y zrZS_+g-cs;vDS>*SUgzAgqZCLjWKo;t&Jtyanms#nHQ1gwo*|{tTw7=8&ICF&L<~U zt-6^X2u8+5WDiER%6($4dPunUp!-@hNiW$8?VNWK?_hGi1j_q_{GT|Js3iF%&JPIP zOGsJuwK!g`^|4PLb|y=;fp+F%Crk>IpS{;?3hD;*LzIL!)7je0i@+D}YBrk-pJ2d6 znyAiqqIB|wovGf+CK%DpLy4UpSz?!spUTX?dlR^6P)<07a?$dXVaHDl=*Ah#OpKQl z$7i_-uq4bCh`>WEvSztc-wkM8}ETQEI9Q-j0g@1 zzUMY-l)%3d@N=Z|nHC!An>Z)@w6Avrr<&gvnoiVwB>Z$%p9)SrqQHBaZ)3#~b>S-NIlM>ef#yv*Z*c1Qy6dC9lEW+SXwfpRWs#mWwrE(b>tODZo3s54 z#`>;_)hgqj<$6lq%48I;;3x<7?dw%WNt9KLlGXG4K?Q5gTZT^^_0&ECd`uajOzEzY zaSA47&{g~^R3?ivC)DxY!>Vcy9T>5*XSxw%L(1N +#include +#include +#include + +#define MARKER_TO "to:" +#define MARKER_BEGIN "--EMOTP_BEGIN--" +#define MARKER_END "--EMOTP_END--" + +/** Packaged up encrypted message, ready for transport. */ +typedef struct _PACKAGE +{ + unsigned long offset; + char *pad_name; + char *cipher_text; +} PACKAGE; + +typedef struct _PAD +{ + char *local_filename; + char *name; + unsigned long offset; + FILE *fp; + struct _PAD *next; +} PAD; + +PAD *pads = NULL; + +void add_pad(PAD *new_pad) +{ + if (!pads) + { + pads = new_pad; + } + else + { + PAD *p, *tail; + + /* Find tail */ + for (p = pads; p; p = p->next) + tail = p; + tail->next = new_pad; + } +} + +void show_pads() +{ + PAD *p; + + printf("h=%.8x\n", (unsigned int)pads); + for (p = pads; p; p = p->next) + { + printf("Pad: %s: %s (next=%.8x)\n", p->name, p->local_filename, + (unsigned int)p->next); + } +} + +void load_pad(char *local_filename) +{ + FILE *fp; + PAD *new_pad; + + fp = fopen("/Volumes/Not Backed Up/otp/otp-dazzlement", "rb"); + if (!fp) + { + perror("fopen"); + exit(EXIT_FAILURE); + } + + new_pad = malloc(sizeof(PAD)); + if (!new_pad) + { + perror("malloc"); + exit(EX_UNAVAILABLE); + } + + new_pad->local_filename = strdup(local_filename); + new_pad->name = NULL; + /* TODO: new_pad->offset = */ + new_pad->fp = fp; + new_pad->next = NULL; + + add_pad(new_pad); + add_pad(new_pad); + + free(new_pad); +} + +int main() +{ + load_pad("/Volumes/Not Backed Up/otp/otp-dazzlement"); + show_pads(); + + return 0; +} + -- 2.11.4.GIT