From 4253e1088f072431aa5d74ddb4f7eea72eb5c399 Mon Sep 17 00:00:00 2001 From: TLINDEN Date: Sat, 1 Mar 2014 18:51:25 +0100 Subject: [PATCH] rewrote z85 stream decoder (again), using hyphens again. clearsig doesn't work yet, a newline problem... --- include/pcp/defines.h | 14 ++++---- include/pcp/mgmt.h | 8 ++--- libpcp/pcpstream.c | 78 +++++++++++++++++++++++++++++++------------ libpcp/z85.c | 50 ++++++++++++++++++++++++--- tests/bart.pub | 16 ++++----- tests/key-alicia-pub | 16 ++++----- tests/key-alicia-sec | 16 ++++----- tests/key-bobby-pub | 16 ++++----- tests/key-bobby-sec | 16 ++++----- tests/keys.cfg | 8 ++--- tests/pipetest.c | 2 -- tests/static.h | 46 ++++++++++++------------- tests/streamtest.c | 5 ++- tests/unknown1 | 16 ++++----- tests/unknown2 | 16 ++++----- tests/unknown4 | 1 + 16 files changed, 201 insertions(+), 123 deletions(-) diff --git a/include/pcp/defines.h b/include/pcp/defines.h index be3e5b8..deea5e4 100644 --- a/include/pcp/defines.h +++ b/include/pcp/defines.h @@ -58,15 +58,15 @@ typedef unsigned short dbyte; /* Double byte = 16 bits */ typedef unsigned int qbyte; /* Quad byte = 32 bits */ /* key stuff, deprecated. */ -#define PCP_ENFILE_HEADER "~~~~~ BEGIN PCP ENCRYPTED FILE ~~~~~\r\n" -#define PCP_ENFILE_FOOTER "\r\n~~~~~ END PCP ENCRYPTED FILE ~~~~~\r\n" +#define PCP_ENFILE_HEADER "----- BEGIN PCP ENCRYPTED FILE -----\r\n" +#define PCP_ENFILE_FOOTER "\r\n----- END PCP ENCRYPTED FILE -----\r\n" -#define PCP_ZFILE_HEADER "~~~~~ BEGIN Z85 ENCODED FILE ~~~~~" -#define PCP_ZFILE_FOOTER "~~~~~ END Z85 ENCODED FILE ~~~~~" +#define PCP_ZFILE_HEADER "----- BEGIN Z85 ENCODED FILE -----" +#define PCP_ZFILE_FOOTER "----- END Z85 ENCODED FILE -----" -#define PCP_SIG_HEADER "~~~~~ BEGIN ED25519 SIGNED MESSAGE ~~~~~" -#define PCP_SIG_START "~~~~~ BEGIN ED25519 SIGNATURE ~~~~~" -#define PCP_SIG_END "~~~~~ END ED25519 SIGNATURE ~~~~~" +#define PCP_SIG_HEADER "----- BEGIN ED25519 SIGNED MESSAGE -----" +#define PCP_SIG_START "----- BEGIN ED25519 SIGNATURE -----" +#define PCP_SIG_END "----- END ED25519 SIGNATURE -----" #define PCP_SIGPREFIX "\nnacl-" #define PCP_ME "Pretty Curved Privacy" diff --git a/include/pcp/mgmt.h b/include/pcp/mgmt.h index 521005a..765fc4b 100644 --- a/include/pcp/mgmt.h +++ b/include/pcp/mgmt.h @@ -109,10 +109,10 @@ typedef struct _pcp_ks_bundle_t pcp_ks_bundle_t; #define EXP_SIG_SUB_KEYFLAGS 27 /* in armored mode, we're using the usual head+foot */ -#define EXP_PK_HEADER "~~~~~BEGIN ED25519-CURVE29915 PUBLIC KEY~~~~~" -#define EXP_PK_FOOTER "~~~~~END ED25519-CURVE29915 PUBLIC KEY~~~~~" -#define EXP_SK_HEADER "~~~~~BEGIN ED25519-CURVE29915 PRIVATE KEY~~~~~" -#define EXP_SK_FOOTER "~~~~~END ED25519-CURVE29915 PRIVATE KEY~~~~~" +#define EXP_PK_HEADER "----- BEGIN ED25519-CURVE29915 PUBLIC KEY -----" +#define EXP_PK_FOOTER "----- END ED25519-CURVE29915 PUBLIC KEY -----" +#define EXP_SK_HEADER "----- BEGIN ED25519-CURVE29915 PRIVATE KEY -----" +#define EXP_SK_FOOTER "----- END ED25519-CURVE29915 PRIVATE KEY -----" /* pubkey export formats */ diff --git a/libpcp/pcpstream.c b/libpcp/pcpstream.c index b60057b..e010682 100644 --- a/libpcp/pcpstream.c +++ b/libpcp/pcpstream.c @@ -114,6 +114,8 @@ size_t ps_read_raw(Pcpstream *stream, void *buf, size_t readbytes) { } } + // fprintf(stderr, " ps_read_raw, idx: %ld, readbytes: %ld\n", idx, readbytes); + if(stream->is_buffer) { /* check if there's enough space in our buffer */ if(buffer_left(stream->b) < readbytes) @@ -144,23 +146,24 @@ size_t ps_read_raw(Pcpstream *stream, void *buf, size_t readbytes) { that */ size_t ps_read_cached(Pcpstream *stream, void *buf, size_t readbytes) { - + /* fprintf(stderr, "%ld <= %ld && %ld <= %ld\n", readbytes, buffer_left(stream->cache), readbytes, stream->blocksize) ; - fprintf(stderr, "%d == 1 && %ld >= %ld\n", ps_left(stream), readbytes, buffer_left(stream->cache)); - + fprintf(stderr, "%d == 1 && %ld >= %ld\n", + ps_end(stream), readbytes, buffer_left(stream->cache)); + */ if(readbytes <= buffer_left(stream->cache) && readbytes <= stream->blocksize) { /* enough left in current cache */ - fprintf(stderr, " get all from cache\n"); + // fprintf(stderr, " get all from cache\n"); return buffer_get_chunk(stream->cache, buf, readbytes); } else if(ps_end(stream) == 1 && readbytes >= buffer_left(stream->cache) ) { - fprintf(stderr, " get rest from cache\n"); + // fprintf(stderr, " get rest from cache\n"); return buffer_get_chunk(stream->cache, buf, buffer_left(stream->cache)); } else { - fprintf(stderr, " fetch next\n"); + // fprintf(stderr, " fetch next\n"); /* request for chunk larger than what we've got in the cache */ Buffer *tmp = buffer_new(stream->blocksize, "Pcpreadchunktmp"); @@ -169,7 +172,7 @@ size_t ps_read_cached(Pcpstream *stream, void *buf, size_t readbytes) { buffer_get_chunk_tobuf(stream->cache, tmp, buffer_left(stream->cache)); } -#error EOF reached, cache empty, save filled, doesnt call ps_read_next() + //#error EOF reached, cache empty, save filled, doesnt call ps_read_next() /* how much left to fetch */ long int left = readbytes - buffer_size(tmp); @@ -177,8 +180,10 @@ size_t ps_read_cached(Pcpstream *stream, void *buf, size_t readbytes) { /* fetch and decode data until tmp is filled */ while (left > 0) { /* not enough cached, fetch the next chunk */ + // fprintf(stderr, " fetch next read_next\n"); if(ps_read_next(stream) == 0) break; + // fprintf(stderr, " fetch next read_continue\n"); /* need to fetch more? */ left = readbytes - (buffer_size(tmp) + buffer_size(stream->next)); @@ -220,6 +225,7 @@ size_t ps_read_cached(Pcpstream *stream, void *buf, size_t readbytes) { /* read and decode the next chunk and put it into stream->next */ size_t ps_read_next(Pcpstream *stream) { + // fprintf(stderr, " ps_read_next ps_left: %d, ps_end: %d, save_left: %ld\n", ps_left(stream), ps_end(stream), buffer_left(stream->save)); if(ps_left(stream) == 0 || buffer_left(stream->save)) { if(stream->armor == 1) { /* fetch next chunk and decode it */ @@ -245,7 +251,7 @@ size_t ps_read(Pcpstream *stream, void *buf, size_t readbytes) { else if(buffer_size(stream->cache) > 0) { /* use cache */ got = ps_read_cached(stream, buf, readbytes); - fprintf(stderr, "%ld = use cache directly\n", got); + // fprintf(stderr, "%ld = use cache directly\n", got); } else { /* no cache yet */ @@ -254,13 +260,13 @@ size_t ps_read(Pcpstream *stream, void *buf, size_t readbytes) { recursively call ps_read() again to return the apropriate data */ ps_determine(stream); got = ps_read(stream, buf, readbytes); - fprintf(stderr, "%ld = ps_read(stream, buf, readbytes);\n", got); + // fprintf(stderr, "%ld = ps_read(stream, buf, readbytes);\n", got); } else if(stream->armor == 1) { /* z85 encoding has already been determined, therefore the cache is now filled, use it then */ got = ps_read_cached(stream, buf, readbytes); - fprintf(stderr, "%ld = ps_read_cached(stream, buf, readbytes);\n", got); + // fprintf(stderr, "%ld = ps_read_cached(stream, buf, readbytes);\n", got); } else { /* read directly from source */ @@ -269,27 +275,33 @@ size_t ps_read(Pcpstream *stream, void *buf, size_t readbytes) { } stream->pos += got; - fprintf(stderr, " ps_read(): %ld\n", got); + // fprintf(stderr, " ps_read(): %ld\n", got); return got; } int ps_readline(Pcpstream *stream, Buffer *line) { - int c = 0, max = 1; + int c = -1, max = 1; byte b[1]; while(csave); + // buffer_info(stream->save); + - if(buffer_left(stream->save) >= stream->blocksize && stream->firstread == 1) { + if(buffer_left(stream->save) > stream->blocksize){// && stream->firstread == 1) { /* use the save buffer instead */ + /* fprintf(stderr, " ps_read_next get chunk from save %ld >= %ld\n", + buffer_left(stream->save), stream->blocksize); */ buffer_get_chunk_tobuf(stream->save, z, stream->blocksize); } else if(ps_left(stream) == 1 && buffer_left(stream->save) > 0) { /* there's something left which doesn't end in a newline */ - buffer_get_chunk_tobuf(stream->save, z, stream->blocksize); + // fprintf(stderr, " ps_read_next which doesn't end in a newline\n"); + buffer_get_chunk_tobuf(stream->save, z, buffer_left(stream->save)); + buffer_dump(z); + fatals_ifany(); } else { /* continue reading linewise */ + // fprintf(stderr, " ps_read_next while(%ld < %ld)\n", buffer_size(z), stream->blocksize); while(buffer_size(z) < stream->blocksize) { buffer_clear(line); if(ps_readline(stream, line) >= 0) { - fprintf(stderr, "got: <%s>\n", buffer_get_str(line)); + // fprintf(stderr, "got: <%s>\n", buffer_get_str(line)); if(z85_isbegin(line) && stream->have_begin == 0) { /* begin header encountered */ stream->have_begin = 1; /* otherwise ignore it */ @@ -373,17 +394,21 @@ size_t ps_read_decode(Pcpstream *stream) { } else { /* regular z85 encoded content */ - fprintf(stderr, "regular\n"); + // fprintf(stderr, "regular\n"); + // fprintf(stderr, " %ld + %ld > %ld\n", buffer_size(z), buffer_size(line), stream->blocksize); if(buffer_size(z) + buffer_size(line) > stream->blocksize) { /* we've got more than needed. put what we need into z and the remainder into the save buffer for further reading. */ - fprintf(stderr, "overflow %ld + %ld > %ld\n", + /* fprintf(stderr, "overflow %ld + %ld > %ld\n", buffer_size(z), buffer_size(line), stream->blocksize); - + */ buffer_get_chunk_tobuf(line, z, stream->blocksize - buffer_size(z)); buffer_get_chunk_tobuf(line, stream->save, buffer_left(line)); - buffer_add8(stream->save, '\n'); + if(!ps_left(stream)) { + /* only add the newline if there's no more to follow */ + buffer_add8(stream->save, '\n'); + } break; } else { @@ -393,17 +418,19 @@ size_t ps_read_decode(Pcpstream *stream) { } } else { + // fprintf(stderr, " ps_read_next readline returned 0\n"); /* eof or err */ break; } } } - fprintf(stderr, "Z: <%s>\n", buffer_get_str(z)); + // fprintf(stderr, "Z: <%s>\n", buffer_get_str(z)); /* finally, decode it and put into next */ size_t binlen, outlen; byte *bin = pcp_z85_decode(buffer_get_str(z), &binlen); + fatals_ifany(); if(bin == NULL) { /* it's not z85 encoded, so threat it as binary */ if(stream->firstread) { @@ -421,6 +448,7 @@ size_t ps_read_decode(Pcpstream *stream) { else { /* yes, successfully decoded it, put into cache */ buffer_add(stream->next, bin, binlen); + // fprintf(stderr, "ps_read_decode decoded: <%s>\n", buffer_get_str(stream->next)); outlen = binlen; } @@ -626,6 +654,11 @@ void ps_close(Pcpstream *stream) { } int ps_end(Pcpstream *stream) { + /* bail out if we have errors! */ + if(ps_err(stream)) { + return 1; + } + /* simulate open file if there's still something in the cache */ if(stream->cache != NULL) { if(buffer_left(stream->cache) > 0) { @@ -645,7 +678,7 @@ int ps_left(Pcpstream *stream) { /* used internally to determine if we reached end of source */ if(stream->is_buffer) { if(buffer_left(stream->b) == 0) - return 1; + return 1; /* true, more to read */ else return 0; } @@ -665,3 +698,4 @@ size_t ps_tell(Pcpstream *stream) { Buffer *ps_buffer(Pcpstream *stream) { return stream->b; } + diff --git a/libpcp/z85.c b/libpcp/z85.c index fa36548..52474dc 100644 --- a/libpcp/z85.c +++ b/libpcp/z85.c @@ -267,7 +267,7 @@ char *pcp_readz85file(FILE *infile) { return pcp_readz85string(input, bufsize); } -char *pcp_readz85string(byte *input, size_t bufsize) { +char *pcp_readz85string(unsigned char *input, size_t bufsize) { size_t i; size_t MAXLINE = 1024; @@ -282,12 +282,50 @@ char *pcp_readz85string(byte *input, size_t bufsize) { } Buffer *z = buffer_new(MAXLINE, "z"); - uint8_t is_comment = 0; + Buffer *line = buffer_new(MAXLINE, "line"); + int begin, end; + begin = end = 0; char *out = NULL; - for(i=0; i 0 && end != 1) { + /* something left in line buffer, probably + newline at eof missing or no multiline input */ + buffer_add_buf(z, line); + } if(buffer_size(z) == 0) { fatal("empty z85 encoded string"); @@ -298,15 +336,19 @@ char *pcp_readz85string(byte *input, size_t bufsize) { strncpy(out, buffer_get_str(z), buffer_size(z)+1); buffer_free(z); + buffer_free(line); return out; rferr: buffer_free(z); + buffer_free(line); return NULL; } + + int z85_isheader(Buffer *buf) { size_t len = buffer_size(buf); byte *line = buffer_get(buf); diff --git a/tests/bart.pub b/tests/bart.pub index 906d8bb..2d4277a 100644 --- a/tests/bart.pub +++ b/tests/bart.pub @@ -1,8 +1,8 @@ -~~~~~BEGIN ED25519-CURVE29915 PUBLIC KEY~~~~~ -22+[E/=.$41#M]-p3Z*%mJukC}Az}B1oy^NZQodOb+b/vpHh6fA/A944@{IMelG{62mGJ -m9=#BHf}C+wnm]q@Ts>0&wN0UDH>Rm7+]8@<[fYHG>Em7026*4BOF5#qVZBr+RPvPrmFy:# -v5khdlw:Ym>>*%uPeej4FJk^>lj{byzcNiGCk#%?ht]4ni@+5PJxsHLFb/MH -~~~~~END ED25519-CURVE29915 PUBLIC KEY~~~~~ +----- BEGIN ED25519-CURVE29915 PUBLIC KEY ----- +22=cP^iizk/S(7@mlSgf@6nh%u@zErhpi[-k6qjn6%ok*g5#O]e.QB3MuuWrixpn12 +2n4nKEzxTj8xsVxIq[Zy?5q0?AVs^G$%P8DW#AkLv6l5E6vUi0R*9FJb5Cobo^9)000040- +GZL^eTdD1oRS{qbEq[00AQc]heu+000Gy00SAaB7GxavqD(T=>lrU01xRx1POWzCwZ#jlsB +[R0000i6Awmo3tx*3M*i@UAy.o5#svC=hxAbY +xhb5hzpC7b6=IE5cD9H@b!fWP{2pbLNtYH8+-n0Yj=vzBX2T>[lMq-q5i*2l)PdG:BIPA2B +D4^a6a@jiPj@$B.!^!{]aAy))63hk{cXx}mn51fTD6^]V{p9p-sQ6ahG-z8M +----- END ED25519-CURVE29915 PUBLIC KEY ----- diff --git a/tests/key-alicia-pub b/tests/key-alicia-pub index 2a4afe5..435dee1 100644 --- a/tests/key-alicia-pub +++ b/tests/key-alicia-pub @@ -1,8 +1,8 @@ -~~~~~BEGIN ED25519-CURVE29915 PUBLIC KEY~~~~~ -22+[E!fex*BR+=DXNjIW*d]B9yhJyNrMg0#a!%V*Xbws>g4J+ -iHwx}-&tG+bR-@GioqlzuJq[GE*3My.aX]SmgU:zaB%=y].Owpf1Al4i0FCA>lF<{mMi$2> -s=p/)jfQgIX:Qi:EGr6&^d)R2%a/@Th!*(Uhi>$WMI+l}oi%=1Yj[(RwQ{deEeY}+=ZwmlP)g)@xo9^e/o*Inh/D$%Byb76oY5FWb{*A)%P+ +)ZLI]woam72W7o+2/0jlexvmVD$M@D@AkVO{ifxYN+3nlzTKbo^om]kmdAkbo^9)000040- +GZL=J0}B1oRS{qbme(00AQc]hel.000Gy00SAaB7GxavqF>%B3xT801P+z1PO:BCwZ#jl2p +mBx<*#w02caE1on6]>5bo+9J*O +AOZK#pb[R/]4Ioj#%g-^K&wXGZo%RVL-krtAo2KlE5+mZwVYEq42qBn%fbgnj!xKjo0K]]z +f!ons/5<$-FV9)bOo(6V -d5=Wl5FnFQ{.7iH(:rE?Yjnxx*H#Vx*qH5H1zGu-x9OgK.aqgH+k[aID6Qef^.98y=X(Umu -zUH0tlM6TJ/Egz./:3/^QtOu?CvSBC>6[gto2J&gQhxFhOir4qen:9QXK)y]q80zoP6L^eBLW^%Rk4T3ex% -M[UiZ6c:4)PaZfE+$QZWql}6F:AYon8w-Tb=o8lvmo/rgn8B)7/d->8iP(}dS8:{t5uV@rp9F0MYzVSgf}Gc634x[9-. +POiO2U@x?M.]-wh&(AZs/?fl+9VjZ6rG[83B{R2ea46qKluMru0Y69SJEhRMiQ->e)O(^+a +D[o:v+-Ar6pN14lCcuT^z@-+sc1ThHsoyM@g3Kq2CcBV7mfCQku]hBJ]6[dc[15h([VK/ +vbO}-9sLnK8)7$d.?ktw>dV:@TF*&.zW3a*fq +----- END ED25519-CURVE29915 PRIVATE KEY ----- diff --git a/tests/key-bobby-pub b/tests/key-bobby-pub index fb6a8cb..ea51193 100644 --- a/tests/key-bobby-pub +++ b/tests/key-bobby-pub @@ -1,8 +1,8 @@ -~~~~~BEGIN ED25519-CURVE29915 PUBLIC KEY~~~~~ -22+[E!/&)#+yclyjgq?Y9P}g0]H-5>PqR?^-neRWuv(BqUQ0q -wUX:VK[pL!I6viWj2ubRztI:1pwzz9!Kc*H53+pMJIjUfHMo@]qo%0yI:7]bo^9)000040- -GFA/8L^J1oRS&Qe}r{00AQc)4NIX000Gy00SAaB7GxavqE8AG8U/J01GXy1POZACwZ#jlt{ -sxC(N*A6bgAH01iTLx(4l%vQ:QFy&r/(yYBCn0uh2*MY}4Ts:6[Y!T3tzq-D:XF-Dq*srnDc^)ed+.9wMS76]gnTr+Chj!dz%]vUIqNK)IH+Y.}tzSp4dx -O9$ZdRB[0N5QD#hgeq:29t9${Mmoyhkd=1.vK6]iPGRk*enlj:zE=ZU:J -~~~~~END ED25519-CURVE29915 PUBLIC KEY~~~~~ +----- BEGIN ED25519-CURVE29915 PUBLIC KEY ----- +22=cP=MQ@$kcRI7M[87Bi==H8)/6i=N4ii}CC6f1>{n#*c$?20!?rH/53vrzKE7yrSPozm? +f{MwT-aHF0Mf)!G9ru!SWUY%EnzqN/*RW0rYJpZs4W4+fdpxm/}VwG9!1bibo^9)000040- +GZL=&s4C1oRS{qbvk)00AQc]heo-000Gy00SAaB7GxavqLXYcBr:M01GXy1POZACwZ#jlt{ +sxC(N*A6bgAH01iTLx(4l%vQ:QFy&r/(yYBCn0uh1IMK+J*Y9:&N>]?bs[A(ErLawU^uC6AN8aYdY+YLx%v&Jwf?Fc{SdDtM)SQ!TKSP?+9#Xz +]YmYNEeK=yWu^5p.!!gxhWZ[.vlJFb)%iL&FvJ*/&#yG:dAKBY0Y7UdjTiM0 +----- END ED25519-CURVE29915 PUBLIC KEY ----- diff --git a/tests/key-bobby-sec b/tests/key-bobby-sec index 31f37cb..df8a439 100644 --- a/tests/key-bobby-sec +++ b/tests/key-bobby-sec @@ -1,8 +1,8 @@ -~~~~~BEGIN ED25519-CURVE29915 PRIVATE KEY~~~~~ -s/Kxk/+qqBnP!erxq{]ai6+BkWc{nC=Xy+i9}+LSR)ZfN5Cm*4[N?Ra!JFm]*POClYeTcw) -q[juqJ-}Pi1ht!j8l$IM8nLKaIfY/JuITR:J5#j/#H3dFY=YWW%AhfyCm2@+nzd12SL(]i$ -#Za6b%^GyG[U.qS%tHb5YvVQg/4KvdEEoM!}Cxk[ci3sRA$aeSngGa6Slj5z&u7/^kNX2h* -(*yV15+HfdwcE&H/k<5*Ih2Iik+1F^WJJIK@7jE>jmQS0P5)sZi#ZaLOI>-q-ShW$%i(h>V -Th(wzVmBnjg2a32wZ5xyf?PkbNmh!oza-3PL2$itvb)ih/yK!%HP}*iaS@+CPSJdjb.q-iG -+MIh1CxgeRL*Scd+e&F%o.pMf2p>LMHYtBH0]SuWZJ3f:6(&%TgAW&05e1}3 -~~~~~END ED25519-CURVE29915 PRIVATE KEY~~~~~ +----- BEGIN ED25519-CURVE29915 PRIVATE KEY ----- +S^GIheT!sgshqj^LryKM]Y7vR@.o(u6[%F7(He@*uc(2%5kjiz*pd^A}^(8Q/f2^l*SJ@IGsq#{M7pZvDry*NrYj7qAE+?tAxv62smKN/=4 +P^n)3zfJ+:u3/)((]zF/8Bk82}TwRjx3uSMoV8lNA6yi][L4[(TU56VZi +8Inn$F2jF-qDee{q}p3E0b{W^2%r?8zSFfXj[?&bXJ6)]@^qlM)w)kH+@ejn+$]vh(92L9EW&Ny(R=+/r2 +ej.gJ(1ll3+D5m&KQyEkC+W{vn!u>1+6rNd1Yv$%+z0#d!J3:lC-hASAA9JS +----- END ED25519-CURVE29915 PRIVATE KEY ----- diff --git a/tests/keys.cfg b/tests/keys.cfg index c587b1a..35fe918 100644 --- a/tests/keys.cfg +++ b/tests/keys.cfg @@ -1,6 +1,6 @@ -bartid = 0x81E0427F3EE40B39 -bartserial = 0xEDCCBD5B -idbobby = 0xEDF476444C8B5721 -idalicia = 0xD467BA4B3187236F +bartid = 0x4EF5795E2874AD8D +bartserial = 0x1B4ED012 +idbobby = 0x969D5931D7B409C6 +idalicia = 0x629AFD2418EFA3BA mailbobby = bobby@local mailalicia = alicia@local diff --git a/tests/pipetest.c b/tests/pipetest.c index 030d1eb..1621793 100644 --- a/tests/pipetest.c +++ b/tests/pipetest.c @@ -50,11 +50,9 @@ int main(int argc, char **argv) { void *buf = ucmalloc(rblocksize); while(!ps_end(in)) { - fprintf(stderr, "=== read:\n"); got = ps_read(in, buf, rblocksize); if(got > 0) ps_write(out, buf, got); - fprintf(stderr, "======= got: %ld\n", got); } ps_finish(out); diff --git a/tests/static.h b/tests/static.h index 49e0013..4f70e4d 100644 --- a/tests/static.h +++ b/tests/static.h @@ -1,33 +1,33 @@ size_t secret_a_len = 32; unsigned char secret_a[32] = { -0x48, 0x59, 0xdb, 0xdb, 0x16, 0xfe, 0xa0, 0x17, -0xc8, 0x34, 0x38, 0x32, 0x29, 0x41, 0x56, 0xf1, -0x35, 0x5d, 0x20, 0x52, 0xa2, 0x54, 0xeb, 0x67, -0xb2, 0xd9, 0x5d, 0xa2, 0x90, 0xbc, 0x19, 0x55 +0xd0, 0xb0, 0x71, 0x2c, 0x3f, 0x08, 0xc2, 0x74, +0x55, 0x72, 0x32, 0xb0, 0x12, 0x9b, 0x5b, 0x88, +0x96, 0x38, 0xf8, 0xa4, 0xca, 0x4b, 0x0f, 0xc5, +0x0c, 0xd0, 0xd1, 0xd7, 0xbe, 0x83, 0x31, 0x75 }; size_t public_a_len = 32; unsigned char public_a[32] = { -0xfd, 0x9e, 0x3b, 0xe5, 0x99, 0x13, 0x22, 0xf6, -0xc8, 0x42, 0x10, 0x6e, 0x75, 0xd5, 0xe4, 0xcd, -0x1d, 0x69, 0xbf, 0x31, 0xbc, 0xfc, 0x2c, 0x27, -0xb7, 0xd2, 0x0f, 0xcc, 0xa6, 0x6e, 0x92, 0x38 +0xdd, 0x1a, 0xc0, 0xcf, 0xb2, 0xb9, 0x69, 0x7b, +0x60, 0x31, 0x98, 0x12, 0x9e, 0xe4, 0x5c, 0x6e, +0x3b, 0xe4, 0x91, 0x98, 0x26, 0x67, 0xd4, 0x75, +0xb7, 0x2f, 0xb3, 0xdf, 0xb6, 0x9d, 0x0a, 0x60 }; size_t secret_b_len = 32; unsigned char secret_b[32] = { -0x88, 0x06, 0xfd, 0x5d, 0x6f, 0x45, 0xd0, 0x0e, -0xea, 0x66, 0xc9, 0xdc, 0xda, 0x38, 0xd4, 0xa8, -0x06, 0x81, 0xd9, 0x31, 0x9b, 0x22, 0x2d, 0xef, -0x4e, 0x69, 0x00, 0xc4, 0x8c, 0xdf, 0x4e, 0x44 +0x18, 0xc9, 0x0f, 0xcd, 0xa7, 0x76, 0x0a, 0x5b, +0xc2, 0x8a, 0x3a, 0x06, 0xf6, 0xfe, 0xbd, 0xbb, +0x7b, 0x99, 0x63, 0x4c, 0xf6, 0x5e, 0xf8, 0x2c, +0x1e, 0x53, 0x16, 0x2e, 0x75, 0xba, 0x16, 0x53 }; size_t public_b_len = 32; unsigned char public_b[32] = { -0xdc, 0xc2, 0xcf, 0xe2, 0xc9, 0x3e, 0xe0, 0xf7, -0x33, 0x6f, 0xb8, 0xab, 0xe4, 0xb4, 0xe1, 0x6d, -0x82, 0xcb, 0xcc, 0xfa, 0x83, 0xc4, 0x8d, 0x09, -0x6f, 0x24, 0xec, 0xe0, 0xf3, 0x93, 0xce, 0x73 +0x70, 0xb6, 0xe2, 0x75, 0x4d, 0x30, 0x3f, 0xef, +0x01, 0xd8, 0xfe, 0xe2, 0x83, 0x62, 0xda, 0x8f, +0x53, 0xb2, 0x35, 0xa6, 0x23, 0x39, 0xca, 0x3c, +0xb9, 0x81, 0x34, 0x2b, 0x5f, 0x5b, 0xe8, 0x45 }; size_t message_len = 12; @@ -38,16 +38,16 @@ unsigned char message[12] = { size_t nonce_len = 24; unsigned char nonce[24] = { -0x5e, 0xa0, 0xbd, 0x53, 0x16, 0xbf, 0x91, 0x2d, -0xfc, 0xe7, 0x1c, 0x0d, 0x4c, 0x9f, 0x79, 0xd1, -0x4d, 0x98, 0x3c, 0x2b, 0x1e, 0x47, 0x35, 0x0d +0x1f, 0x54, 0xb8, 0x13, 0x86, 0x6c, 0xc4, 0x8b, +0xd1, 0x92, 0x27, 0x5e, 0x40, 0xc2, 0x91, 0x2a, +0x96, 0x1a, 0xed, 0x57, 0xa1, 0xda, 0xcd, 0x41 }; size_t cipher_len = 28; unsigned char cipher[28] = { -0xac, 0x06, 0x36, 0x4d, 0xd0, 0xa7, 0x58, 0x4e, -0x18, 0x35, 0x99, 0x29, 0x2b, 0x1e, 0x4a, 0x08, -0x1e, 0xcd, 0xd3, 0xc7, 0xce, 0x4a, 0xd1, 0xa7, -0x3e, 0x78, 0x94, 0xe9 +0xca, 0x76, 0xac, 0x81, 0x94, 0x06, 0x52, 0x45, +0x5e, 0xa6, 0x15, 0xd5, 0xda, 0x5a, 0xef, 0xf9, +0x7b, 0x32, 0x2c, 0x5d, 0x7d, 0x3d, 0xd5, 0x3a, +0xba, 0x03, 0x67, 0x73 }; diff --git a/tests/streamtest.c b/tests/streamtest.c index 3c57b33..2e47f0a 100644 --- a/tests/streamtest.c +++ b/tests/streamtest.c @@ -18,8 +18,11 @@ int linetest() { byte data[9] = {0}; while(!ps_end(pin)) { if((got = ps_read(pin, data, 8)) > 0) { - fwrite(data, 1, got, stdout); + fprintf(stderr, "######## <"); + fwrite(data, 1, got, stderr); + fprintf(stderr, "> ##### %ld\n", got); } + else break; } ps_close(pin); diff --git a/tests/unknown1 b/tests/unknown1 index 6c04693..69f8a86 100644 --- a/tests/unknown1 +++ b/tests/unknown1 @@ -1,8 +1,8 @@ -~~~~~BEGIN ED25519-CURVE29915 PUBLIC KEY~~~~~ -22+[E*94)L5kvZrVv&2kb@a+ka?%vr7IZ=d{$(<%-=#gX8ADWg*Hk+Am.OW&C&JDg]N*z:O -M:v9Sk$22F$*)4g3fMPo*O$G+1Wf>8TwQm[E)pySYiO(:W7k9Rj=R]njrL3bo^9)000040- -GFA*w?iN1oRS&QfvP$00AQc)4NU-000Gy00SAaB7GxavqI(09ThPA01Y?A1PO^CCwZ#jpha -oRvqYPQ000-F00Aohzddc{zFrW0vqYQvy&r/(yYBCn0uh4nIbbYbli}YJqFx*f&5(&p]*s$+m?0k>MX[/@M?w(&Jj&%XwQuNd@xjgj0E:5f +a+QYbckn^v%JYx?zn!?r6s=^[YD=@=&tdePs33mqP?27*z[G7D?AZ=K#-Q=bo^9)000040- +GZL^F%mE1oRS{qbNw]00AQc]hex=000Gy00SAaB7GxavqF-?7ovGo01Y?A1PO^CCwZ#jpha +oRvqYPQ000-F00Aohzddc{zFrW0vqYQvy&r/(yYBCn0uh1/YcqT!v.kt618SvO+4etVdRS: +R?.g@uS82E}:k@-9.%zQ?.(#NDzTXmy2>kX4H$!/3lCchFQ:xW/.=N[6vnsJJhx*o5< -~~~~~END ED25519-CURVE29915 PRIVATE KEY~~~~~ +----- BEGIN ED25519-CURVE29915 PRIVATE KEY ----- +e/x3zay4]W1sjBNZ^>rtpjy&2>%u3*(rRZoSUGJjv>.C3J92f(9q9st5Ul*y^1jzS.dxMTgkN3u)D+6Vq/DwI(6.H^ +Gy+I&&=*4G9zD.ywRMkk[[[S^QiXSgQ$&l[^w{Z41$[9NwxiR0XISj0RH&qnJoPu96m3eaT +odtIGYU.U36qL5=bU00rQnSJ.3cQcx&GgIAWeMO0>$/-kTyw1C*cYd-bX)^Qjr)Bw(?@VD% +z.2DH)v3yJ/$Bd[LlTg=wKp0w*&i]VZAcCpL3Zx8d{+CiGLeT:zgByrh2VxthFA)xj&A#( +----- END ED25519-CURVE29915 PRIVATE KEY ----- diff --git a/tests/unknown4 b/tests/unknown4 index e69de29..2960308 100644 --- a/tests/unknown4 +++ b/tests/unknown4 @@ -0,0 +1 @@ +7YQnZ?kK]LGI?Z4Yof:=q{igA@WHz5fwy*Hiv}wb)d-+*F*2Q=F9zm@ufg?Y