Skip to content

Commit

Permalink
Introduce the s96at library
Browse files Browse the repository at this point in the history
Add s96at.h, which defines and documents the library API
as well as s96at.c which contains the implementation.

Add auxiliary sha.c which contain the implementation
of the SHA-256 padding according to FIPS 180-2.

Update CMakeLists.txt to build libs96at.so.

Remove obsolete files.

Signed-off-by: Michalis Pappas <mpappas@fastmail.fm>
  • Loading branch information
michpappas authored and jbech-linaro committed May 17, 2018
1 parent c21bbf3 commit 0c01fe6
Show file tree
Hide file tree
Showing 9 changed files with 1,035 additions and 37 deletions.
11 changes: 7 additions & 4 deletions s96at/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#set(CMAKE_TOOLCHAIN_FILE CMakeToolchain.txt)
project(s96-204 C)
project(s96at C)

# Required cmake version
cmake_minimum_required(VERSION 3.0.2)
Expand All @@ -11,19 +11,22 @@ MESSAGE(STATUS "CMAKE_C_COMPILER: " ${CMAKE_C_COMPILER})
add_compile_options(-Wall -Werror)
include_directories(include)

set(SRC ${CMAKE_SOURCE_DIR}/src/cmd.c
set(SRC ${CMAKE_SOURCE_DIR}/src/s96at.c
${CMAKE_SOURCE_DIR}/src/cmd.c
${CMAKE_SOURCE_DIR}/src/crc.c
${CMAKE_SOURCE_DIR}/src/debug.c
${CMAKE_SOURCE_DIR}/src/io.c
${CMAKE_SOURCE_DIR}/src/i2c_linux.c
${CMAKE_SOURCE_DIR}/src/packet.c)
${CMAKE_SOURCE_DIR}/src/packet.c
${CMAKE_SOURCE_DIR}/src/sha.c)

set(I2C_DEVICE "/dev/i2c-0")

#add_definitions(-DEXT_DEBUG_INFO)
add_definitions(-DCMAKE_BUILD_TYPE=Debug)

add_executable(${PROJECT_NAME} ${SRC} ${CMAKE_SOURCE_DIR}/src/main.c)
add_library(${PROJECT_NAME} SHARED ${SRC})
set_target_properties(${PROJECT_NAME} PROPERTIES PUBLIC_HEADER include/s96at.h)

target_compile_definitions(${PROJECT_NAME}
PRIVATE -DI2C_DEVICE="${I2C_DEVICE}"
Expand Down
30 changes: 18 additions & 12 deletions s96at/include/cmd.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,35 +21,41 @@ enum {
#define ZONE_OTP_SIZE 64
#define ZONE_DATA_SIZE 512

#define ZONE_CONFIG_NUM_WORDS 22
#define ZONE_DATA_NUM_SLOTS 16
#define ZONE_OTP_NUM_WORDS 16

#define LOCK_CONFIG_LOCKED 0x0
#define LOCK_CONFIG_UNLOCKED 0x55
#define LOCK_DATA_LOCKED 0x0
#define LOCK_DATA_UNLOCKED 0x55

/* Sizes for out parameter (RandOut) */
#define NONCE_SHORT_LEN 1
#define NONCE_LONG_LEN 32

/* Sizes for in parameter (NumIn) */
#define NONCE_SHORT_NUMIN 20
#define NONCE_LONG_NUMIN 32

#define NONCE_MODE_UPDATE_SEED 0
#define NONCE_MODE_NO_SEED 1
#define NONCE_MODE_PASSTHROUGH 3
#define TEMPKEY_SOURCE_RANDOM 0
#define TEMPKEY_SOURCE_INPUT 1

#define HMAC_LEN 32
#define RANDOM_LEN 32
#define DEVREV_LEN 4
#define SERIALNUM_LEN 9
#define MAC_LEN 32
#define SHA_LEN 32
#define SHA_BLOCK_LEN 64

#define WORD_SIZE 4
#define MAX_READ_SIZE 32 /* bytes */
#define MAX_WRITE_SIZE 32

#define MAC_MODE_TEMPKEY_SOURCE_SHIFT 2
#define MAC_MODE_USE_OTP_88_BITS_SHIFT 4
#define MAC_MODE_USE_OTP_64_BITS_SHIFT 5
#define MAC_MODE_USE_SN_SHIFT 6

#define NONCE_MODE_RANDOM 0
#define NONCE_MODE_RANDOM_NO_SEED 1
#define NONCE_MODE_PASSTHROUGH 3

#define SHA_MODE_INIT 0x00
#define SHA_MODE_COMPUTE 0x01

/* Word address values */
#define PKT_FUNC_RESET 0x0
#define PKT_FUNC_SLEEP 0x1
Expand Down
13 changes: 0 additions & 13 deletions s96at/include/defines.h

This file was deleted.

Loading

0 comments on commit 0c01fe6

Please sign in to comment.