Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Openpgp functionality #447

Open
wants to merge 58 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
58 commits
Select commit Hold shift + click to select a range
ba117b8
bump tinycbor version
merlokk Feb 10, 2020
db40031
added openpgp
merlokk Feb 10, 2020
7e5ec50
compile mbedtls and spiffs
merlokk Feb 11, 2020
f3bde0b
remove timing.c
merlokk Feb 11, 2020
f316692
c++ compile sketch
merlokk Feb 11, 2020
4c95040
build clean
merlokk Feb 12, 2020
4b6b704
memory layout sketch
merlokk Feb 12, 2020
d3eafbb
openpgp update
merlokk Feb 12, 2020
55ee547
c++ header for flash.h
merlokk Feb 12, 2020
8dff6c1
disable exceptions
merlokk Feb 12, 2020
4287024
add init
merlokk Feb 12, 2020
67cc5dd
logging
merlokk Feb 12, 2020
96324e5
use 4 free pages
merlokk Feb 12, 2020
88c5a5a
define ABS
merlokk Feb 20, 2020
bf3ad06
added flash write with erase
merlokk Feb 20, 2020
7e73271
fix flash write
merlokk Feb 20, 2020
1183f9c
ccid power on/off sketch, add ccid consts, enable ccid
merlokk Feb 20, 2020
750aa91
added xfr and slot errors
merlokk Feb 22, 2020
b944666
add check voltage for power_on
merlokk Feb 22, 2020
e6afbc8
change data_in epnum
merlokk Feb 22, 2020
7e3e1b5
interrupt sketch
merlokk Feb 23, 2020
a5ae06a
ATR works
merlokk Feb 24, 2020
476e922
ccid parameters for T0 sketch
merlokk Feb 24, 2020
314dd2b
lib exchange c----c++ connect
merlokk Feb 24, 2020
f5c9a4b
led.h can be used from c++ part
merlokk Feb 24, 2020
cb36524
ccid exchange
merlokk Feb 24, 2020
f72f3ac
fix log sending via usb
merlokk Feb 24, 2020
e9ad71f
remove redundant logs
merlokk Feb 24, 2020
40c61f5
add memory place for c++ virtual tables
merlokk Feb 25, 2020
c655d17
device.h can be used from c++ code
merlokk Feb 25, 2020
07b5d05
add PUT_TO_SRAM2 and .sram2 section
merlokk Feb 25, 2020
d4645c4
move some buffers to sram2
merlokk Feb 25, 2020
e601d41
add reset to usb , fix warning
merlokk Feb 26, 2020
e688d3c
added led control to device.c and led and log in reset sequence
merlokk Feb 27, 2020
e2f8e8b
some leds, move reset to device.c
merlokk Feb 27, 2020
92ae479
dwMaxCCIDMessageLength now is 64b
merlokk Mar 4, 2020
b2addc8
add usb ccid chaining. and another 2k buffer there(
merlokk Mar 4, 2020
3783e89
fix some warnings
merlokk Mar 4, 2020
5f80eb8
some changes in ld
merlokk Mar 6, 2020
a6e2726
add stm32fs to solo build
merlokk May 23, 2020
0681ce6
remove spiffs from make
merlokk May 23, 2020
39763dd
bump openpgp. now filesystem works
merlokk May 24, 2020
3f74fe2
add bearssl
merlokk May 25, 2020
d1de2e1
add rsa keygen to makefile and bump openpgp
merlokk May 31, 2020
a50e2e3
remove mbedtls from compiling .bump openpgp.
merlokk Jun 5, 2020
7ad015f
add ecdsa, aes from bearssl to compile. bump openpgp.
merlokk Jun 9, 2020
bedd657
add libsalty and rename some directories
merlokk Jun 10, 2020
2ae85df
update project files. bump openpgp, restore j8 option in makefilke
merlokk Jun 14, 2020
ae03a4b
added libsalty obj files
merlokk Jun 14, 2020
b1d92cd
fix warning
merlokk Jun 14, 2020
239747f
remove some parts of bearssl
merlokk Jun 15, 2020
eaf7a70
remove mbedtls and spiffs
merlokk Jun 15, 2020
752ee73
added some consts for flash part of MCU
merlokk Jun 15, 2020
3e00da5
add optimization macros and delay() to device.c
merlokk Jun 16, 2020
596edee
solo editor files
merlokk Jan 28, 2021
f33258b
Merge branch 'master' into openpgp
merlokk Jan 28, 2021
531f922
remove lines in makefile that blocks build
merlokk Jan 28, 2021
e29d477
fix compiler warning
merlokk Jan 29, 2021
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
Expand Up @@ -16,3 +16,6 @@
[submodule "crypto/salty"]
path = crypto/salty
url = https://github.com/ycrypto/salty.git
[submodule "openpgp"]
path = openpgp
url = https://github.com/solokeys/openpgp.git
Binary file added crypto/libsalty/libsalty-asm.a
Binary file not shown.
Binary file added crypto/libsalty/libsalty.a
Binary file not shown.
120 changes: 120 additions & 0 deletions crypto/libsalty/salty.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,120 @@
#ifndef salty_h
#define salty_h

/* Warning, this file is autogenerated by cbindgen. Don't modify this manually. */

#include <stdarg.h>
#include <stdbool.h>
#include <stdint.h>
#include <stdlib.h>

#ifdef __cplusplus
extern "C" {
#endif

#define salty_COMPRESSED_Y_LENGTH 32
#define salty_PUBLICKEY_SERIALIZED_LENGTH 32
#define salty_SCALAR_LENGTH 32
#define salty_SECRETKEY_NONCE_LENGTH 32
#define salty_SECRETKEY_SCALAR_LENGTH 32
#define salty_SECRETKEY_SEED_LENGTH 32
#define salty_SECRETKEY_SERIALIZED_LENGTH 32
#define salty_SHA256_LENGTH 64
#define salty_SHA512_LENGTH 64
#define salty_SIGNATURE_SERIALIZED_LENGTH 64

/**
* Extensible error type for all `salty` operations.
*
* This enum has a hidden member, to prevent exhaustively checking for errors.
*/
typedef enum {
/**
* Never occurs, simplifies C bindings
*/
NoError = 0,
/**
* Bytes do not correspond to a canonical base field element
*/
NonCanonicalFieldElement,
/**
* Public key bytes invalid
*/
PublicKeyBytesInvalid,
/**
* Signature verification failed
*/
SignatureInvalid,
/**
* Context for prehashed signatures too long
*/
ContextTooLong,
_Extensible,
} salty_Error;

/**
* Generates a public key from a secret seed. Use to verify signatures.
*/
void salty_public_key(const uint8_t (*seed)[salty_SECRETKEY_SEED_LENGTH],
uint8_t (*public_key)[salty_PUBLICKEY_SERIALIZED_LENGTH]);

/**
* Signs the data, based on the keypair generated from the secret seed.
*/
void salty_sign(const uint8_t (*seed)[salty_SECRETKEY_SEED_LENGTH],
const uint8_t *data_ptr,
uintptr_t data_len,
uint8_t (*signature)[salty_SIGNATURE_SERIALIZED_LENGTH]);

/**
* Signs the data for a context, based on the keypair generated from the secret seed.
*/
salty_Error salty_sign_with_context(const uint8_t (*seed)[salty_SECRETKEY_SEED_LENGTH],
const uint8_t *data_ptr,
uintptr_t data_len,
const uint8_t *context_ptr,
uintptr_t context_len,
uint8_t (*signature)[salty_SIGNATURE_SERIALIZED_LENGTH]);

/**
* Signs the prehashed data, based on the keypair generated from the secret seed.
* An optional context can also be passed (this is recommended).
*/
salty_Error salty_sign_prehashed(const uint8_t (*seed)[salty_SECRETKEY_SEED_LENGTH],
const uint8_t (*prehashed_data)[salty_SHA512_LENGTH],
const uint8_t *context_ptr,
uintptr_t context_len,
uint8_t (*signature)[salty_SIGNATURE_SERIALIZED_LENGTH]);

/**
* Verify a presumed signature on the given data.
*/
salty_Error salty_verify(const uint8_t (*public_key)[salty_PUBLICKEY_SERIALIZED_LENGTH],
const uint8_t *data_ptr,
uintptr_t data_len,
const uint8_t (*signature)[salty_SIGNATURE_SERIALIZED_LENGTH]);

/**
* Verify a presumed signature on the given data for a context.
*/
salty_Error salty_verify_with_context(const uint8_t (*public_key)[salty_PUBLICKEY_SERIALIZED_LENGTH],
const uint8_t *data_ptr,
uintptr_t data_len,
const uint8_t *context_ptr,
uintptr_t context_len,
const uint8_t (*signature)[salty_SIGNATURE_SERIALIZED_LENGTH]);

/**
* Verify a presumed signature on the given data.
*/
salty_Error salty_verify_prehashed(const uint8_t (*public_key)[salty_PUBLICKEY_SERIALIZED_LENGTH],
const uint8_t (*prehashed_data)[salty_SHA512_LENGTH],
const uint8_t (*signature)[salty_SIGNATURE_SERIALIZED_LENGTH],
const uint8_t *context_ptr,
uintptr_t context_len);

#ifdef __cplusplus
}
#endif

#endif /* salty_h */
35 changes: 35 additions & 0 deletions fido2/device.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,27 @@
#ifndef _DEVICE_H
#define _DEVICE_H

#include "stdbool.h"
#include "storage.h"

#ifdef __cplusplus
extern "C" {
#endif

#ifndef PUT_TO_SRAM2
#define PUT_TO_SRAM2 __attribute__((section(".sram2")))
#endif

#define COLOR_OFF 0x000000
#define COLOR_WHITE 0xffffff
#define COLOR_GRAY 0x101010
#define COLOR_RED 0xff0000
#define COLOR_GREEN 0x00ff00
#define COLOR_BLUE 0x0000ff
#define COLOR_YELLOW 0xffff00
#define COLOR_CYAN 0x00ffff
#define COLOR_MAGENTA 0xff00ff

/** Return a millisecond timestamp. Does not need to be synchronized to anything.
* *Optional* to compile, but will not calculate delays correctly without a correct implementation.
*/
Expand Down Expand Up @@ -171,6 +190,12 @@ void ctap_overwrite_rk(int index,CTAP_residentKey * rk);
*/
void device_wink();

/** Show color on the led
*
* *Optional*.
*/
void device_led(uint32_t color);

typedef enum {
DEVICE_LOW_POWER_IDLE = 0,
DEVICE_LOW_POWER_FAST = 1,
Expand Down Expand Up @@ -223,4 +248,14 @@ uint16_t device_attestation_cert_der_get_size();
* */
void device_read_aaguid(uint8_t * dst);

/** Sleep.
* @param ms for sleep.
* */
void delay(uint32_t ms);

#ifdef __cplusplus
}
#endif


#endif
1 change: 1 addition & 0 deletions fido2/log.c
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ struct logtag tagtable[] = {
{TAG_NFC_APDU, "NAPDU"},
{TAG_CCID, "CCID"},
{TAG_CM, "CRED_MGMT"},
{TAG_OPENPGP, "OPGP"}
};


Expand Down
1 change: 1 addition & 0 deletions fido2/log.h
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ typedef enum
TAG_NFC_APDU = (1 << 20),
TAG_CCID = (1 << 21),
TAG_CM = (1 << 22),
TAG_OPENPGP = (1 << 23),

TAG_NO_TAG = (1UL << 30),
TAG_FILENO = (1UL << 31)
Expand Down
12 changes: 12 additions & 0 deletions fido2/util.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,4 +19,16 @@ void dump_hex(uint8_t * buf, int size);
#define MAX(a,b) (((a) > (b)) ? (a) : (b))
#endif

#ifndef ABS
#define ABS(a) (((a) > 0) ? (a) : (-a))
#endif

#ifndef OPTIMIZATION_O2
#define OPTIMIZATION_O2 __attribute__((optimize("O2")))
#endif

#ifndef OPTIMIZATION_O0
#define OPTIMIZATION_O0 __attribute__((optimize("O0")))
#endif

#endif
1 change: 1 addition & 0 deletions openpgp
Submodule openpgp added at 459c77
1 change: 1 addition & 0 deletions solo.cflags
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
-std=c17
2 changes: 2 additions & 0 deletions solo.config
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
// Add predefined macros for your project here. For example:
// #define THE_ANSWER 42
1 change: 1 addition & 0 deletions solo.creator
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
[General]
1 change: 1 addition & 0 deletions solo.cxxflags
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
-std=c++17
Loading