Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
What's new
7
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Open sidebar
yids
avr-pager
Commits
0d46deb8
Commit
0d46deb8
authored
Oct 21, 2016
by
yids
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
tx-test and rx-test work now
parent
374054d7
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
47 additions
and
44 deletions
+47
-44
base-tx/rx-test.c
base-tx/rx-test.c
+12
-23
base-tx/tx-test.c
base-tx/tx-test.c
+35
-21
No files found.
base-tx/rx-test.c
View file @
0d46deb8
...
...
@@ -11,28 +11,26 @@
int
main
()
{
struct
pl_ctx
*
rx_ctx
;
struct
pl_keypair
*
rx_kp
;
char
encrypted_message
[
sizeof
(
struct
pl_pagermessage
)];
// initialise the pager
struct
pl_ctx
*
rx_ctx
;
rx_ctx
=
pl_init
();
rx_kp
=
NULL
;
rx_kp
=
(
struct
pl_keypair
*
)
malloc
(
sizeof
(
struct
pl_keypair
));
pl_load_key
(
rx_kp
,
"meinsleusel"
);
/* init */
rx_ctx
=
pl_init
();
/*load keypair */
rx_kp
=
(
struct
pl_keypair
*
)
malloc
(
sizeof
(
struct
pl_keypair
));
pl_load_key
(
rx_kp
,
"rx"
);
pl_load_key_in_list
(
rx_ctx
,
rx_kp
);
pl_print_keylist
(
rx_ctx
);
// memcpy(&context->receiver_compressed_point, &receiver->compressed_point, sizeof(context->receiver_compressed_point));
rx_ctx
->
kp
=
rx_kp
;
/* get message from stdin */
struct
pl_pagermessage
*
message
=
NULL
;
message
=
(
struct
pl_pagermessage
*
)
malloc
(
sizeof
(
struct
pl_pagermessage
));
read
(
STDIN_FILENO
,
message
,
sizeof
(
struct
pl_pagermessage
));
rx_ctx
->
msg
=
message
;
message
=
NULL
;
switch
(
pl_receive_message
(
rx_ctx
))
{
case
0
:
...
...
@@ -50,19 +48,10 @@ int main ()
case
-
4
:
printf
(
"RCV: -4 (key not found)
\n
"
);
break
;
default:
printf
(
"RCV: unknown error
\n
"
);
break
;
}
// while (pl_inbox_next(rx_ctx))
// {
pl_inbox_display
(
rx_ctx
);
// }
// printf("the decrypted message: %s \n", rx_ctx->msg->msg);
return
0
;
pl_inbox_display
(
rx_ctx
);
}
base-tx/tx-test.c
View file @
0d46deb8
...
...
@@ -13,30 +13,44 @@
int
main
()
{
struct
pl_keypair
*
tx_kp
;
char
*
r
x_
pubkey
;
char
clear_message
[]
=
"dit is een test berichtje :) "
;
struct
pl_ctx
*
t
x_
ctx
;
char
clear_message
[]
=
"
Blaat blaat,
dit is een test berichtje :)
, en nog meer en meer en meer 123456744555 blablablablablablabal jajajajaj hee blaat
"
;
/
/
init
ialise the pager
struct
pl_ctx
*
tx_ctx
;
/
*
init
*/
tx_kp
=
NULL
;
tx_ctx
=
pl_init
();
tx_kp
=
(
struct
pl_keypair
*
)
malloc
(
sizeof
(
struct
pl_keypair
));
pl_load_key
(
tx_kp
,
"sender.keypair"
);
// load tx keypair
rx_pubkey
=
malloc
(
crypto_box_PUBLICKEYBYTES
);
pl_load_public_key
(
rx_pubkey
,
"receiver.pub"
);
// load tx keypair
/* load keypair */
tx_kp
=
(
struct
pl_keypair
*
)
malloc
(
sizeof
(
struct
pl_keypair
));
pl_load_key
(
tx_kp
,
"tx"
);
tx_ctx
->
kp
=
tx_kp
;
memcpy
(
tx_ctx
->
msg
->
msg
,
clear_message
,
MSG_SIZE
);
memcpy
(
&
tx_ctx
->
receiver_public_key
,
rx_pubkey
,
crypto_box_PUBLICKEYBYTES
);
// DBM("context->recv_comp_point", sizeof(tx_ctx->kp->private_key), &context->receiver_compressed_point);
pl_send_message
(
tx_ctx
);
write
(
STDOUT_FILENO
,
tx_ctx
->
msg
,
sizeof
(
struct
pl_pagermessage
));
return
0
;
/*load public key of receiver*/
char
*
rx_pubkey
;
rx_pubkey
=
malloc
(
crypto_box_PUBLICKEYBYTES
);
pl_load_public_key
(
rx_pubkey
,
"rx.pub"
);
memcpy
(
tx_ctx
->
msg
->
msg
,
clear_message
,
MSG_SIZE
);
// copy clear msg into context
memcpy
(
&
tx_ctx
->
receiver_public_key
,
rx_pubkey
,
sizeof
(
tx_ctx
->
receiver_public_key
));
// copy rx pubkey into context
switch
(
pl_send_message
(
tx_ctx
))
{
// send msg
case
0
:
printf
(
"SEND: OK!
\n
"
);
break
;
case
-
1
:
printf
(
"SEND: -1
\n
"
);
break
;
case
-
2
:
printf
(
"SEND: -2
\n
"
);
break
;
case
-
3
:
printf
(
"SEND: -3
\n
"
);
break
;
default:
printf
(
"SEND: unknown error
\n
"
);
break
;
}
write
(
STDOUT_FILENO
,
tx_ctx
->
msg
,
sizeof
(
struct
pl_pagermessage
));
// dump to stdout
////// RRRRXXXX /////////
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment