Commit 77a2b1cf authored by bernd's avatar bernd

Sign messages

parent ec43e68d
......@@ -15,23 +15,42 @@
\ You should have received a copy of the GNU Affero General Public License
\ along with this program. If not, see <http://www.gnu.org/licenses/>.
get-current also net2o-base definitions
$52 net2o: msg ( -- ) \ push a message object
msg-context @ n:>o ;
msg-context @ n:>o buf-state 2@ msg-buf 2! ;
msg-table >table
reply-table $@ inherit-table msg-table
$20 net2o: msg-at ( timestamp -- ) \ specify sender time
." msg at: " .ticks space ;
net2o' emit net2o: msg-at ( timestamp -- ) \ specify sender time
parent @ .pubkey $@ key-table #@
IF cell+ .ke-nick $@ F type ELSE drop parent @ .pubkey $@ 85type THEN
." [" .ticks ." ]: " ;
+net2o: msg-text ( $:msg -- ) \ specify message string
$> F type F cr ;
$> F type ;
+net2o: msg-object ( $:hash -- ) \ specify an object, e.g. an image
$> F ." wrapped object: " 85type F cr ;
$> ." wrapped object: " 85type F cr ;
+net2o: msg-sig ( $:signature -- ) \ detached signature
$>
msg-buf 2@ drop buf-state 2@ drop over - 3 - 2 pick - c:0key c:hash
keysize 2* <> !!keysize!!
parent @ .pubkey $@ keysize <> !!keysize!! ed-verify .check F cr ;
gen-table $freeze
' context-table is gen-table
set-current
User <msg-buf
: <msg ( -- ) msg cmdbuf$ + <msg-buf ! ;
: msg> ( -- ) <msg-buf @ cmdbuf$ + over -
c:0key c:hash skc pkc ed-sign $, msg-sig endwith ;
previous
0 [IF]
Local Variables:
forth-local-words:
......
......@@ -873,6 +873,7 @@ cmd-class class
end-class ack-class
cmd-class class
2field: msg-buf
end-class msg-class
cmd-class class
......@@ -2491,8 +2492,8 @@ con-cookie >osize @ buffer: cookie-adder
require net2o-cmd.fs
require net2o-dht.fs
require net2o-msg.fs
require net2o-keys.fs \ extra cmd space
require net2o-msg.fs
0 [IF]
Local Variables:
......@@ -2500,7 +2501,7 @@ forth-local-words:
(
(("event:") definition-starter (font-lock-keyword-face . 1)
"[ \t\n]" t name (font-lock-function-name-face . 3))
(("debug:" "field:" "sffield:" "dffield:" "64field:") non-immediate (font-lock-type-face . 2)
(("debug:" "field:" "2field:" "sffield:" "dffield:" "64field:") non-immediate (font-lock-type-face . 2)
"[ \t\n]" t name (font-lock-variable-name-face . 3))
("[a-z\-0-9]+(" immediate (font-lock-comment-face . 1)
")" nil comment (font-lock-comment-face . 1))
......
......@@ -18,12 +18,11 @@ init-client
?nextarg [IF] s>number drop to net2o-port [THEN]
: c:msg-test ( -- )
[: .time ." Download test: 1 text file and 2 photos" cr ;] $err
[: .time ." Message test" cr ;] $err
net2o-code
expect-reply
log !time .time s" Message test" $, type cr endwith
msg ticks lit, msg-at
"This is a test message" $, msg-text endwith
<msg ticks lit, msg-at
"This is a test message" $, msg-text msg>
cookie+request
end-code| ['] .time $err
>timing do-disconnect [: .packets profile( .times ) ;] $err ;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment