Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
A
avr-pager
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
1
Issues
1
List
Boards
Labels
Service Desk
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Incidents
Environments
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
yids
avr-pager
Commits
b1f17f08
Commit
b1f17f08
authored
Nov 16, 2016
by
yids
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
- added cleanup function
- some testing stuff
parent
3c9a3635
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
50 additions
and
11 deletions
+50
-11
avr-src/Makefile
avr-src/Makefile
+4
-4
avr-src/lib-test.c
avr-src/lib-test.c
+16
-5
base-tx/tx-test.c
base-tx/tx-test.c
+3
-1
libs/pagerlib/pagerlib.c
libs/pagerlib/pagerlib.c
+26
-0
libs/pagerlib/pagerlib.h
libs/pagerlib/pagerlib.h
+1
-1
No files found.
avr-src/Makefile
View file @
b1f17f08
...
...
@@ -3,11 +3,11 @@
CFILES
=
blink.c
OBJS
=
../libs/avrnacl/avrnacl_small/obj/randombytes.o ../libs/avrnacl/avrnacl_small/obj/libnacl.a
CFLAGS
=
-Os
-g3
-pedantic
-std
=
gnu99
-DARDUINO
-I
../libs/avrnacl/randombytes
-I
../libs/avrnacl/avrnacl_small/include
CFLAGS
=
-Os
-g
gdb
3
-pedantic
-std
=
gnu99
-DARDUINO
-I
../libs/avrnacl/randombytes
-I
../libs/avrnacl/avrnacl_small/include
OPTIMIZE
=
-O3
CC
=
avr-gcc
MCU
=
atmega
328
MCU
=
atmega
2560
F_CPU
=
F_CPU
=
16000000UL
AVRDUDE_PROGRAMMERID
=
stk200 /
*
Programmer ids are listed
in
/etc/avrdude.conf
*
/
...
...
@@ -25,13 +25,13 @@ upload:
avrdude
-carduino
-p
atmega328p
-P
$(AVRDUDE_PORT)
-b57600
-U
flash:w:lib-test.hex
simulavr
:
simulavr
-
G
-d
$(MCU)
--file
lib-test.elf
&
simulavr
-
t
-g
-d
$(MCU)
--file
lib-test.elf
-W
0x20,-
&
sleep
1
avr-gdb
-se
lib-test.elf
--eval-command
=
"target remote localhost:1212"
--eval-command
=
"load"
killall simulavr
simulavr-ddd
:
simulavr
-
G
-d
$(MCU)
--file
lib-test.elf &
simulavr
-
g
-d
$(MCU)
--file
lib-test.elf &
sleep
1
ddd
--debugger
'avr-gdb -se lib-test.elf --eval-command="target remote localhost:1212" --eval-command="load"'
killall simulavr
...
...
avr-src/lib-test.c
View file @
b1f17f08
...
...
@@ -11,6 +11,9 @@
#include <util/setbaud.h>
#include </usr/local/include/simavr/avr/avr_mcu_section.h>
#define special_output_port (*((volatile char *)0x20))
char
tx_priv_key
[
crypto_box_SECRETKEYBYTES
]
=
{
0x23
,
0x4D
,
0x77
,
0xFFFFFFF7
,
0x09
,
0x70
,
0x46
,
0xFFFFFF82
,
0xFFFFFFC7
,
0x0B
,
0x70
,
0x39
,
0xFFFFFFDA
,
0x24
,
0x4A
,
0xFFFFFF9C
,
0x28
,
0x7A
,
0xFFFFFFD8
,
0xFFFFFFCE
,
0x7B
,
0xFFFFFFEF
,
0xFFFFFFFB
,
0x75
,
0x7E
,
0x34
,
0x16
,
0xFFFFFF99
,
0xFFFFFFF6
,
0x60
,
0x08
,
0x0A
};
char
tx_comp_p
[
crypto_box_PUBLICKEYBYTES
]
=
{
0xFFFFFFC1
,
0xFFFFFFEF
,
0xFFFFFF89
,
0xFFFFFFA8
,
0x66
,
0x44
,
0xFFFFFFD6
,
0x72
,
0x26
,
0xFFFFFF84
,
0xFFFFFFA9
,
0xFFFFFFF5
,
0xFFFFFF9A
,
0xFFFFFFFC
,
0xFFFFFF88
,
0x38
,
0xFFFFFFA3
,
0x1D
,
0x71
,
0x05
,
0xFFFFFFB9
,
0x0A
,
0x0F
,
0xFFFFFFF3
,
0xFFFFFF93
,
0xFFFFFFEF
,
0x48
,
0xFFFFFFA1
,
0xFFFFFFB7
,
0x49
,
0xFFFFFF90
,
0x6D
};
...
...
@@ -23,14 +26,20 @@ char clear_message[] = "dit is een test berichtje :) ";
struct
pl_ctx
*
context
;
void
debug_puts
(
const
char
*
str
)
{
const
char
*
c
;
for
(
c
=
str
;
*
c
;
c
++
)
special_output_port
=
*
c
;
}
int
main
(
void
)
{
uart_init
();
uart_print
(
"haaalloo"
);
//
uart_init();
//
uart_print("haaalloo");
debug_puts
(
"start main
\n
"
);
struct
pl_keypair
*
tx_kp
;
struct
pl_ctx
*
tx_ctx
;
...
...
@@ -49,9 +58,11 @@ int main(void)
memcpy
(
tx_ctx
->
receiver_public_key
,
rx_comp_p
,
crypto_box_PUBLICKEYBYTES
);
memcpy
(
tx_ctx
->
msg
->
msg
,
clear_message
,
MSG_SIZE
);
debug_puts
(
"loaded msg
\n
"
);
pl_send_message
(
tx_ctx
);
//debug_puts("processed msg\n");
//uart_print("set keys and proces msg\n");
// pl_send_message(tx_ctx);
// uart_print("set keys and proces msg\n");
//******** rx ***********/
...
...
base-tx/tx-test.c
View file @
b1f17f08
...
...
@@ -57,6 +57,8 @@ int main()
break
;
}
write
(
STDOUT_FILENO
,
tx_ctx
->
msg
,
sizeof
(
struct
pl_pagermessage
));
// dump to stdout
pl_cleanup
(
tx_ctx
);
free
(
pubkey
);
////// RRRRXXXX /////////
return
0
;
}
libs/pagerlib/pagerlib.c
View file @
b1f17f08
...
...
@@ -117,7 +117,11 @@ inline int pl_send_message(struct pl_ctx *ctx) {
memset
(
temp_plain
,
'\0'
,
crypto_box_ZEROBYTES
);
memcpy
(
temp_plain
+
crypto_box_ZEROBYTES
,
ctx
->
msg
->
msg
,
PLAIN_MSG_SIZE
);
//char nonce[crypto_box_NONCEBYTES];
#ifdef ARDUINO
memset
(
&
ctx
->
msg
->
nonce
,
0
,
crypto_box_NONCEBYTES
);
//FIXME this is for testing purposes and should be changed
#else
randombytes
(
ctx
->
msg
->
nonce
,
crypto_box_NONCEBYTES
);
#endif
rc
=
crypto_box
(
temp_encrypted
,
temp_plain
,
crypto_box_ZEROBYTES
+
PLAIN_MSG_SIZE
,
ctx
->
msg
->
nonce
,
ctx
->
receiver_public_key
,
ctx
->
kp
->
secret_key
);
if
(
rc
!=
0
)
return
-
1
;
...
...
@@ -518,4 +522,26 @@ int pl_inbox_display_all(struct pl_ctx *ctx)
}
}
pl_cleanup
(
struct
pl_ctx
*
ctx
)
{
#ifndef ARDUINO
struct
list_kp
*
list_kp
;
struct
list_public_key
*
list_pk
;
struct
list_inbox
*
list_inbox
;
printf
(
"cleaning up...
\n
"
);
for
(
list_kp
=
ctx
->
keypairs
;
list_kp
!=
NULL
;
list_kp
=
list_kp
->
next
)
free
(
list_kp
->
kp
);
for
(
list_pk
=
ctx
->
public_keys
;
list_pk
!=
NULL
;
list_pk
=
list_pk
->
next
)
free
(
list_pk
->
public_key
);
for
(
list_inbox
=
ctx
->
inbox
;
list_inbox
!=
NULL
;
list_inbox
=
list_inbox
->
next
)
free
(
list_inbox
->
msg
);
free
(
ctx
->
kp
);
free
(
ctx
->
msg
);
//free(ctx->receiver_public_key);
free
(
ctx
->
keypairs
);
free
(
ctx
->
public_keys
);
free
(
ctx
->
inbox
);
free
(
ctx
);
#endif
}
libs/pagerlib/pagerlib.h
View file @
b1f17f08
...
...
@@ -119,7 +119,7 @@ int pl_inbox_display(struct pl_ctx *ctx);
int
pl_inbox_next
(
struct
pl_ctx
*
ctx
);
int
pl_inbox_prev
(
struct
pl_ctx
*
ctx
);
int
pl_inbox_delete
(
struct
pl_ctx
*
ctx
);
pl_cleanup
(
struct
pl_ctx
*
ctx
);
int
is_zero
(
const
char
*
data
,
int
len
);
#ifdef __cplusplus
...
...
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