Check-in [aa10c71e44]
Not logged in

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

Overview
Comment:Chat images started, delivery of dht with obsolete date prevented
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1: aa10c71e4425be9c2d1eea45933fb4fd28b2c438
User & Date: bernd 2019-11-27 21:26:18
Context
2019-11-27
21:43
Fix old my-addr$ problem check-in: 52a229cf9c user: bernd tags: trunk
21:26
Chat images started, delivery of dht with obsolete date prevented check-in: aa10c71e44 user: bernd tags: trunk
2019-11-26
22:05
Auto-load avatar check-in: 721303536c user: bernd tags: trunk
Changes
Hide Diffs Unified Diffs Ignore Whitespace Patch

Changes to crypt.fs.

574
575
576
577
578
579
580




581
582
583
584
585
586
587
enum sig-wrong
enum sig-ok
drop

: early/late? ( n64 min64 max64 -- sig-error )
    64>r 64over 64r> 64u>= sig-late and >r 64u< sig-early and r> min ;





: check-date ( addr u -- addr u flag )
    2dup + 1- c@ keysize <> sig-keysize and ?dup-IF  EXIT  THEN
    2dup enddate@ 64>r 2dup startdate@ 64>r
    ticks fuzzedtime# 64+ 64r> 64r>
    64dup 64#-1 64<> IF  fuzzedtime# 64-2* 64+  THEN
    early/late?
    msg( dup IF  <err> ." sig out of date: " ticks .ticks ."  sigdate: "







>
>
>
>







574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
enum sig-wrong
enum sig-ok
drop

: early/late? ( n64 min64 max64 -- sig-error )
    64>r 64over 64r> 64u>= sig-late and >r 64u< sig-early and r> min ;

: check-exact-date ( addr u -- addr u flag )
    2dup + 1- c@ keysize <> sig-keysize and ?dup-IF  EXIT  THEN
    2dup enddate@ 64>r 2dup startdate@ 64>r
    ticks 64r> 64r> early/late? ;
: check-date ( addr u -- addr u flag )
    2dup + 1- c@ keysize <> sig-keysize and ?dup-IF  EXIT  THEN
    2dup enddate@ 64>r 2dup startdate@ 64>r
    ticks fuzzedtime# 64+ 64r> 64r>
    64dup 64#-1 64<> IF  fuzzedtime# 64-2* 64+  THEN
    early/late?
    msg( dup IF  <err> ." sig out of date: " ticks .ticks ."  sigdate: "

Changes to dht.fs.

284
285
286
287
288
289
290

291
292


293
294
295
296
297
298
299
    2swap 2 pick d#c, 2swap
    2over rot umin dup >r move r> /string ;
: d#id, ( addr u -- addr' u' )
    0 d#c, dht-hash $@ d#$, ;
: d#values, ( addr u mask -- addr' u' ) { mask }
    k#size cell/ 1 DO
	mask 1 and IF

	    I dup cells dht-hash dht( ." access dht: " dup hex. over . forth:cr ) +
	    [: { k# a# u# } k# d#c, a# u# d#$, k# ;] $[]map drop


	THEN  mask 2/ to mask
    LOOP ;

:noname 64#-1 64dup to fs-limit to fs-size ;
dht-file-class to fs-open

:noname ( addr u -- n )  dup >r







>
|
<
>
>







284
285
286
287
288
289
290
291
292

293
294
295
296
297
298
299
300
301
    2swap 2 pick d#c, 2swap
    2over rot umin dup >r move r> /string ;
: d#id, ( addr u -- addr' u' )
    0 d#c, dht-hash $@ d#$, ;
: d#values, ( addr u mask -- addr' u' ) { mask }
    k#size cell/ 1 DO
	mask 1 and IF
	    dht-hash I cells + I
	    dht( ." access dht: " over hex. dup . forth:cr )

	    [{: k# :}l check-exact-date
		0= IF  k# d#c, d#$,  ELSE  2drop  THEN ;] $[]map
	THEN  mask 2/ to mask
    LOOP ;

:noname 64#-1 64dup to fs-limit to fs-size ;
dht-file-class to fs-open

:noname ( addr u -- n )  dup >r

Changes to msg.fs.

1605
1606
1607
1608
1609
1610
1611

















1612

1613

1614
1615
1616
1617
1618
1619
1620
: http-rec ( addr u -- )
    2dup "https://" string-prefix? >r
    2dup "http://" string-prefix? r> or IF
	over ?flush-text 2dup + to last->in
	[: $, msg-url ;] rectype-name
    ELSE  2drop rectype-null  THEN ;


















$Variable msg-recognizer

' text-rec ' http-rec ' chain-rec ' tag-rec ' pk-rec 5 msg-recognizer set-stack


: parse-text ( addr u -- ) last# >r  forth-recognizer >r
    0 to last->in
    msg-recognizer to forth-recognizer 2dup evaluate
    last->in IF  + last->in tuck -  THEN  dup IF
	\ ." text: '" forth:type ''' forth:emit forth:cr
	$, msg-text







>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>

>
|
>







1605
1606
1607
1608
1609
1610
1611
1612
1613
1614
1615
1616
1617
1618
1619
1620
1621
1622
1623
1624
1625
1626
1627
1628
1629
1630
1631
1632
1633
1634
1635
1636
1637
1638
1639
: http-rec ( addr u -- )
    2dup "https://" string-prefix? >r
    2dup "http://" string-prefix? r> or IF
	over ?flush-text 2dup + to last->in
	[: $, msg-url ;] rectype-name
    ELSE  2drop rectype-null  THEN ;

forward hash-in

: jpeg? ( addr u -- flag )
    dup 4 - 0 max safe/string ".jpg" str= ;
: img-rec ( addr u -- )
    2dup "img:" string-prefix? IF
	over ?flush-text 2dup + to last->in
	2dup jpeg? IF
	    2dup >thumbnail
	    ?dup-IF  over >r hash-in r> free throw  THEN
	ELSE  #0.  THEN
	2swap slurp-file over >r hash-in r> free throw
	[: type dup IF  type img-orient 1- 0 max emit  ELSE  2drop  THEN ;] $tmp
	[: tuck $, >r msg:thumbnail# msg:image# r> $20 u> select ulit,
	    msg-object ;] rectype-name
    ELSE  2drop rectype-null  THEN ;

$Variable msg-recognizer
depth >r
' text-rec ' img-rec ' http-rec ' chain-rec ' tag-rec ' pk-rec
depth r> - msg-recognizer set-stack

: parse-text ( addr u -- ) last# >r  forth-recognizer >r
    0 to last->in
    msg-recognizer to forth-recognizer 2dup evaluate
    last->in IF  + last->in tuck -  THEN  dup IF
	\ ." text: '" forth:type ''' forth:emit forth:cr
	$, msg-text

Changes to net2o.fs.

38
39
40
41
42
43
44

45
46
47
48
49
50
51
require keccak.fs
require threefish.fs
keccak-o crypto-o !
require rng.fs
require ed25519-donna.fs
require hash-table.fs
require bdelta.fs


\ random initializer for hash

: hash-init-rng ( -- )  $10 rng$ hashinit swap move ;

hash-init-rng








>







38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
require keccak.fs
require threefish.fs
keccak-o crypto-o !
require rng.fs
require ed25519-donna.fs
require hash-table.fs
require bdelta.fs
require minos2/jpeg-exif.fs

\ random initializer for hash

: hash-init-rng ( -- )  $10 rng$ hashinit swap move ;

hash-init-rng