Check-in [2ef7582d7f]
Not logged in

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
Comment:Checkin from holiday
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1:2ef7582d7f3801e04f6343737b4f350465c3e371
User & Date: bernd 2019-07-26 06:17:55
Context
2019-07-26
06:51
Checkin from holiday check-in: ee04913b0a user: bernd tags: trunk
06:17
Checkin from holiday check-in: 2ef7582d7f user: bernd tags: trunk
2019-07-15
23:36
Try to make otrify work with encrypted messages — tricky, still doesn't work check-in: 30bcd87cd1 user: bernd tags: trunk
Changes
Hide Diffs Unified Diffs Ignore Whitespace Patch

Changes to crypt.fs.

707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
	    msg $free
	    err  EXIT  THEN  THEN
    2drop msg $free  0 0 err ;

: .encsign-rest ( -- )
    sigdate +date
    sigdate datesize# type
    sig-params 2drop sktmp pkmod ed-sign
    2dup + 1- $80 swap orc! type
    keysize emit ;

: .encsign ( -- )
    +sig
    sktmp pkmod sk@ drop >modkey
    pkmod keysize type .encsign-rest ;







|







707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
	    msg $free
	    err  EXIT  THEN  THEN
    2drop msg $free  0 0 err ;

: .encsign-rest ( -- )
    sigdate +date
    sigdate datesize# type
    sksig@ drop sktmp pkmod ed-sign
    2dup + 1- $80 swap orc! type
    keysize emit ;

: .encsign ( -- )
    +sig
    sktmp pkmod sk@ drop >modkey
    pkmod keysize type .encsign-rest ;

Changes to gui.fs.

1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
: (gui-msgs) ( gaddr u -- )
    reset-time
    64#0 to last-tick  last-bubble-pk $free
    0 to msg-par  0 to msg-box
    msgs-box .dispose-childs
    glue*lll }}glue msgs-box .child+
    2dup load-msg
    gui-msgs# msg-log@
    { log u } u r> - 0 max { u' }  log u' ?search-lock
    log u u' /string bounds ?DO
	I $@ { d: msgt }
	msgt ['] wmsg-display wmsg-o .catch IF
	    <err> ." invalid entry" <default> 2drop
	THEN
    cell +LOOP
    log free throw  msgs-box >o resized vp-bottom o>







|
|







1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
: (gui-msgs) ( gaddr u -- )
    reset-time
    64#0 to last-tick  last-bubble-pk $free
    0 to msg-par  0 to msg-box
    msgs-box .dispose-childs
    glue*lll }}glue msgs-box .child+
    2dup load-msg
    msg-log@
    { log u } u gui-msgs# cells - 0 max { u' }  log u' ?search-lock
    log u u' /string bounds ?DO
	I $@ { d: msgt }
	msgt ['] wmsg-display wmsg-o .catch IF
	    <err> ." invalid entry" <default> 2drop
	THEN
    cell +LOOP
    log free throw  msgs-box >o resized vp-bottom o>

Changes to msg.fs.

525
526
527
528
529
530
531

532
533
534
535
536
537


538
539
540
541
542
543
544
545
...
550
551
552
553
554
555
556



557
558
559
560
561
562
563
...
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
....
1210
1211
1212
1213
1214
1215
1216
1217

1218
1219
1220

1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
....
1493
1494
1495
1496
1497
1498
1499
1500
1501
1502
1503
1504
1505
1506
1507
1508
1509
1510
1511
1512
1513
    ELSE  pk-sig?  THEN ;

: msg-dec?-sig? ( addr u -- addr' u' flag )
    2dup 2 - + c@ $80 and IF  msg-dec-sig?  ELSE  msg-sig?  THEN ;

: replace-sig { addrsig usig addrmsg umsg -- }
    addrsig usig addrmsg umsg usig - [: type type ;] $tmp

    2dup msg-dec?-sig? !!sig!! 2drop addrmsg umsg smove ;
: new-otrsig ( addr u -- addrsig usig )
    2dup startdate@ old>otr
    predate-key keccak# c:key@ c:key# smove
    + 2 - c@ $80 and >r
    ['] .encsign-rest ['] .sig r> select


    $tmp 1 64s /string ;

:noname { sig u' addr u -- }
    u' 64'+ u =  u sigsize# = and IF
	last# >r last# $@ >group
	addr u startdate@ 64dup date>i >r 64#1 64+ date>i' r>
	2dup = IF  ."  [otrified] "  addr u startdate@ .ticks  THEN
	U+DO
................................................................................
		    ."  OTRify #" I u.
		    sig u' I msg-group-o .msg:log[] $[]@ replace-sig
		    save-msgs&
		ELSE
		    ."  [OTRified] #" I u.
		THEN
	    ELSE



		2drop
	    THEN
	LOOP
	r> to last#
    THEN ; msg-class is msg:otrify

:noname ( -- )
................................................................................
    $> $make
    <event last-msg 2@ e$, elit, o elit, msg-group-o elit, :>chat-reconnect
    parent .wait-task @ ?query-task over select event> ;
+net2o: msg-last? ( start end n -- ) 64>n msg:last? ;
+net2o: msg-last ( $:[tick0,msgs,..tickn] n -- ) 64>n msg:last ;

net2o' nestsig net2o: msg-nestsig ( $:cmd+sig -- ) \g check sig+nest
    $> 2dup nest-sig ?dup-0=-IF
	handle-msg
    ELSE  replay-mode @ IF  drop 2drop 2drop
	ELSE  !!sig!!  THEN \ balk on all wrong signatures
    THEN ;

\ generate an encryt+sign packet

: ]encpksign ( -- )
    +zero16 nest$
    0 msg-group-o .msg:keys[] $[]@ encrypt$
................................................................................

also net2o-base

: do-otrify ( n -- ) >r
    msg-group$ $@ >group msg-group-o .msg:log[] $@
    r> cells dup 0< IF  over + 0 max  THEN safe/string
    IF  $@
	2dup + 2 - c@ $80 and IF  msg-dec-sig? drop  THEN

	2dup + sigpksize# - sigpksize#
	over keysize pk@ key| str= IF
	    keysize /string 2swap new-otrsig 2swap

	    $, $, msg-otrify
	ELSE
	    2drop 2drop ." not your message!" forth:cr
	THEN
    ELSE  drop  THEN ;

previous

\ debugging aids for classes

................................................................................
    msg-group$ $@ >group purge-log
    r>  display-lastn ; is /log

:noname ( addr u -- )
    ['] logstyles evaluate-in ; is /logstyle

:noname ( addr u -- )
    msg-group-o .msg:mode dup @ msg:otr# or swap
    [: now>otr
	[: BEGIN  bl $split 2>r dup  WHILE  s>number? WHILE
			drop do-otrify  2r>  REPEAT THEN
	    2drop 2r> 2drop
	;] (send-avalanche) drop .chat save-msgs&
    ;] !wrapper ; is /otrify

:noname ( addr u -- )
    msg-group-o .msg:-lock
    word-args ['] args>keylist execute-parsing
    [: key-list v-enc$ $, net2o-base:msg-lock ;] send-avalanche
    vkey keysize $make msg-group-o .msg:keys[] >back
    msg-group-o .msg:+lock







>

|
|

<
|
>
>
|







 







>
>
>







 







|

|
|







 







|
>


|
>
|

|







 







<
<
|
|
|
|
<







525
526
527
528
529
530
531
532
533
534
535
536

537
538
539
540
541
542
543
544
545
546
547
...
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
...
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
....
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
....
1500
1501
1502
1503
1504
1505
1506


1507
1508
1509
1510

1511
1512
1513
1514
1515
1516
1517
    ELSE  pk-sig?  THEN ;

: msg-dec?-sig? ( addr u -- addr' u' flag )
    2dup 2 - + c@ $80 and IF  msg-dec-sig?  ELSE  msg-sig?  THEN ;

: replace-sig { addrsig usig addrmsg umsg -- }
    addrsig usig addrmsg umsg usig - [: type type ;] $tmp
    2dup dump
    2dup msg-dec?-sig? !!sig!! 2drop addrmsg umsg smove ;
: new-otrsig ( addr u flag -- addrsig usig )
    >r 2dup startdate@ old>otr
    predate-key keccak# c:key@ c:key# smove

    [: sktmp pkmod sk@ drop >modkey .encsign-rest ;]
    ['] .sig r@ select $tmp
    2dup + 2 - r> swap orc!
    2dup dump 1 64s /string ;

:noname { sig u' addr u -- }
    u' 64'+ u =  u sigsize# = and IF
	last# >r last# $@ >group
	addr u startdate@ 64dup date>i >r 64#1 64+ date>i' r>
	2dup = IF  ."  [otrified] "  addr u startdate@ .ticks  THEN
	U+DO
................................................................................
		    ."  OTRify #" I u.
		    sig u' I msg-group-o .msg:log[] $[]@ replace-sig
		    save-msgs&
		ELSE
		    ."  [OTRified] #" I u.
		THEN
	    ELSE
		."  ID mismatch: "
		2dup dup sigpksize# - /string key| 85type space
		msg:id$ 85type forth:cr
		2drop
	    THEN
	LOOP
	r> to last#
    THEN ; msg-class is msg:otrify

:noname ( -- )
................................................................................
    $> $make
    <event last-msg 2@ e$, elit, o elit, msg-group-o elit, :>chat-reconnect
    parent .wait-task @ ?query-task over select event> ;
+net2o: msg-last? ( start end n -- ) 64>n msg:last? ;
+net2o: msg-last ( $:[tick0,msgs,..tickn] n -- ) 64>n msg:last ;

net2o' nestsig net2o: msg-nestsig ( $:cmd+sig -- ) \g check sig+nest
    $> nest-sig ?dup-0=-IF
	handle-msg
    ELSE  replay-mode @ IF  drop  ELSE  !!sig!!  THEN
	2drop 2drop \ balk on all wrong signatures
    THEN ;

\ generate an encryt+sign packet

: ]encpksign ( -- )
    +zero16 nest$
    0 msg-group-o .msg:keys[] $[]@ encrypt$
................................................................................

also net2o-base

: do-otrify ( n -- ) >r
    msg-group$ $@ >group msg-group-o .msg:log[] $@
    r> cells dup 0< IF  over + 0 max  THEN safe/string
    IF  $@
	2dup + 2 - c@ $80 and dup >r
	IF  msg-dec-sig?  ELSE  pk-sig?  THEN  !!sig!!
	2dup + sigpksize# - sigpksize#
	over keysize pk@ key| str= IF
	    keysize /string $,
	    r> new-otrsig $,
	    msg-otrify
	ELSE
	    rdrop 2drop 2drop ." not your message!" forth:cr
	THEN
    ELSE  drop  THEN ;

previous

\ debugging aids for classes

................................................................................
    msg-group$ $@ >group purge-log
    r>  display-lastn ; is /log

:noname ( addr u -- )
    ['] logstyles evaluate-in ; is /logstyle

:noname ( addr u -- )


    [: BEGIN  bl $split 2>r dup  WHILE  s>number? WHILE
		    drop do-otrify  2r>  REPEAT THEN
	2drop 2r> 2drop  now>otr
    ;] (send-avalanche) drop .chat save-msgs& ; is /otrify


:noname ( addr u -- )
    msg-group-o .msg:-lock
    word-args ['] args>keylist execute-parsing
    [: key-list v-enc$ $, net2o-base:msg-lock ;] send-avalanche
    vkey keysize $make msg-group-o .msg:keys[] >back
    msg-group-o .msg:+lock