
5 changed files with 89 additions and 0 deletions
@ -0,0 +1,12 @@
|
||||
PKG_NAME=tweetnacl
|
||||
PKG_URL=https://github.com/RIOT-OS/tweetnacl
|
||||
PKG_VERSION=7ea05c7098a16c87fa66e9166ce301666f3f2623
|
||||
PKG_LICENSE=PD
|
||||
|
||||
.PHONY: all |
||||
|
||||
all: git-download |
||||
@cp $(RIOTBASE)/pkg/tweetnacl/src/* $(PKG_BUILDDIR)
|
||||
"$(MAKE)" -C $(PKG_BUILDDIR)
|
||||
|
||||
include $(RIOTBASE)/pkg/pkg.mk |
@ -0,0 +1 @@
|
||||
INCLUDES += -I$(BINDIRBASE)/pkg/$(BOARD)/tweetnacl/
|
@ -0,0 +1,44 @@
|
||||
# TweetNaCl RIOT package |
||||
TweetNaCl is the world's first auditable high-security cryptographic library. |
||||
TweetNaCl fits into just 100 tweets while supporting all 25 of the C NaCl |
||||
functions used by applications. TweetNaCl is a self-contained public-domain C |
||||
library, so it can easily be integrated into applications. |
||||
|
||||
NaCl (pronounced "salt") is a new easy-to-use high-speed software library for |
||||
network communication, encryption, decryption, signatures, etc. NaCl's goal is |
||||
to provide all of the core operations needed to build higher-level |
||||
cryptographic tools. |
||||
|
||||
Of course, other libraries already exist for these core operations. NaCl |
||||
advances the state of the art by improving security, by improving usability, |
||||
and by improving speed. |
||||
|
||||
(from https://nacl.cr.yp.to/ and http://tweetnacl.cr.yp.to/) |
||||
|
||||
You can find the API and more information [here](https://nacl.cr.yp.to/), since |
||||
the sources are not documented due to the aim for fitting in 100 tweets. |
||||
|
||||
## Requirements |
||||
TweetNaCl requires more than 2K of stack, so beware that you're allocating at |
||||
least `THREAD_STACKSIZE_DEFAULT + 2048` bytes. |
||||
|
||||
You can do it easily by adding: |
||||
|
||||
```makefile |
||||
CFLAGS += '-DTHREAD_STACKSIZE_MAIN=(THREAD_STACKSIZE_DEFAULT + 2048)' |
||||
``` |
||||
|
||||
to your makefile. |
||||
|
||||
## Usage |
||||
Just add it as a package in your application: |
||||
|
||||
```makefile |
||||
USEPKG += tweetnacl |
||||
``` |
||||
|
||||
And don't forget to include the header: |
||||
|
||||
```c |
||||
#include <tweetnacl.h> |
||||
``` |
@ -0,0 +1,3 @@
|
||||
MODULE=tweetnacl
|
||||
|
||||
include $(RIOTBASE)/Makefile.base |
@ -0,0 +1,29 @@
|
||||
/*
|
||||
* Copyright (C) 2016 Kaspar Schleiser <kaspar@schleiser.de> |
||||
* |
||||
* This file is subject to the terms and conditions of the GNU Lesser |
||||
* General Public License v2.1. See the file LICENSE in the top level |
||||
* directory for more details. |
||||
*/ |
||||
|
||||
#include <stdint.h> |
||||
#include <string.h> |
||||
|
||||
#include "random.h" |
||||
|
||||
#include <stdio.h> |
||||
|
||||
void randombytes(uint8_t *target, uint64_t n) |
||||
{ |
||||
uint32_t random; |
||||
uint8_t *random_pos = (uint8_t*)&random; |
||||
unsigned _n = 0; |
||||
|
||||
while (n--) { |
||||
if (! (_n++ & 0x3)) { |
||||
random = random_uint32(); |
||||
random_pos = (uint8_t *) &random; |
||||
} |
||||
*target++ = *random_pos++; |
||||
} |
||||
} |
Loading…
Reference in new issue