Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
NOTE: probably better to merge this in pprzlink, seems unnatural here
- Loading branch information
Showing
61 changed files
with
16,258 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
<!DOCTYPE module SYSTEM "module.dtd"> | ||
|
||
<module name="crypto" dir="crypto"> | ||
<doc> | ||
<description> | ||
GEC module | ||
</description> | ||
</doc> | ||
<header> | ||
<file name="crypto.h"/> | ||
</header> | ||
<makefile target="ap"> | ||
<define name="DATALINK_CRYPTO" value="1"/> | ||
<file name="crypto.c"/> | ||
<file name="gec-ke.c"/> | ||
<file name="gec.c"/> | ||
<file name="gcm.c" dir="modules/crypto/aes"/> | ||
<file name="curve25519-donna.c" dir="modules/crypto/curve25519"/> | ||
<file name="ed25519.c" dir="modules/crypto/ed25519"/> | ||
</makefile> | ||
</module> | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,118 @@ | ||
/* | ||
--------------------------------------------------------------------------- | ||
Copyright (c) 1998-2010, Brian Gladman, Worcester, UK. All rights reserved. | ||
The redistribution and use of this software (with or without changes) | ||
is allowed without the payment of fees or royalties provided that: | ||
source code distributions include the above copyright notice, this | ||
list of conditions and the following disclaimer; | ||
binary distributions include the above copyright notice, this list | ||
of conditions and the following disclaimer in their documentation. | ||
This software is provided 'as is' with no explicit or implied warranties | ||
in respect of its operation, including, but not limited to, correctness | ||
and fitness for purpose. | ||
--------------------------------------------------------------------------- | ||
Issue Date: 20/12/2007 | ||
This file contains the definitions required to use AES in C. See aesopt.h | ||
for optimisation details. | ||
*/ | ||
|
||
#ifndef _AES_H | ||
#define _AES_H | ||
|
||
// #include <stdlib.h> | ||
|
||
/* This include is used to find 8 & 32 bit unsigned integer types */ | ||
#include "brg_types.h" | ||
|
||
#if defined(__cplusplus) | ||
extern "C" | ||
{ | ||
#endif | ||
|
||
#define AES_128 /* if a fast 128 bit key scheduler is needed */ | ||
|
||
/* The following must also be set in assembler files if being used */ | ||
|
||
#define AES_ENCRYPT /* if support for encryption is needed */ | ||
#define AES_DECRYPT /* if support for decryption is needed */ | ||
#define AES_REV_DKS /* define to reverse decryption key schedule */ | ||
#define AES_MODES | ||
|
||
#define AES_BLOCK_SIZE 16 /* the AES block size in bytes */ | ||
#define N_COLS 4 /* the number of columns in the state */ | ||
|
||
/* The key schedule length is 11, 13 or 15 16-byte blocks for 128, */ | ||
/* 192 or 256-bit keys respectively. That is 176, 208 or 240 bytes */ | ||
/* or 44, 52 or 60 32-bit words. */ | ||
|
||
#if defined( AES_VAR ) || defined( AES_256 ) | ||
#define KS_LENGTH 60 | ||
#elif defined( AES_192 ) | ||
#define KS_LENGTH 52 | ||
#else | ||
#define KS_LENGTH 44 | ||
#endif | ||
|
||
#define AES_RETURN INT_RETURN | ||
|
||
/* the character array 'inf' in the following structures is used */ | ||
/* to hold AES context information. This AES code uses cx->inf.b[0] */ | ||
/* to hold the number of rounds multiplied by 16. The other three */ | ||
/* elements can be used by code that implements additional modes */ | ||
|
||
typedef union | ||
{ uint_32t l; | ||
uint_8t b[4]; | ||
} aes_inf; | ||
|
||
typedef struct | ||
{ uint_32t ks[KS_LENGTH]; | ||
aes_inf inf; | ||
} aes_encrypt_ctx; | ||
|
||
typedef struct | ||
{ uint_32t ks[KS_LENGTH]; | ||
aes_inf inf; | ||
} aes_decrypt_ctx; | ||
|
||
/* This routine must be called before first use if non-static */ | ||
/* tables are being used */ | ||
|
||
AES_RETURN aes_init(void); | ||
|
||
/* Key lengths in the range 16 <= key_len <= 32 are given in bytes, */ | ||
/* those in the range 128 <= key_len <= 256 are given in bits */ | ||
|
||
#if defined( AES_ENCRYPT ) | ||
|
||
AES_RETURN aes_encrypt_key128(const unsigned char *key, aes_encrypt_ctx cx[1]); | ||
AES_RETURN aes_encrypt(const unsigned char *in, unsigned char *out, const aes_encrypt_ctx cx[1]); | ||
|
||
#endif | ||
|
||
#if defined( AES_DECRYPT ) | ||
|
||
AES_RETURN aes_decrypt_key128(const unsigned char *key, aes_decrypt_ctx cx[1]); | ||
AES_RETURN aes_decrypt(const unsigned char *in, unsigned char *out, const aes_decrypt_ctx cx[1]); | ||
|
||
#endif | ||
|
||
typedef void cbuf_inc(unsigned char *cbuf); | ||
|
||
#define aes_ctr_encrypt aes_ctr_crypt | ||
#define aes_ctr_decrypt aes_ctr_crypt | ||
|
||
AES_RETURN aes_ctr_crypt(const unsigned char *ibuf, unsigned char *obuf, | ||
int len, unsigned char *cbuf, cbuf_inc ctr_inc, aes_encrypt_ctx cx[1]); | ||
|
||
|
||
#if defined(__cplusplus) | ||
} | ||
#endif | ||
|
||
#endif |
Oops, something went wrong.