Skip to content
This repository has been archived by the owner on Jan 6, 2023. It is now read-only.

Commit

Permalink
Removed jwt directory as it has duplicate code in src. (#15)
Browse files Browse the repository at this point in the history
The src directory was made of original files plus some files pulled from
other gir repos. The workflow was supposed to be to edit the original
files in jwt/ directory, call jwt/compile.sh, then copy the output to
src. The new workflow is to edit files in src except for the src/crypto
folder because files in that folder are pulled from external repos.
  • Loading branch information
cirvladimir authored and gguuss committed Apr 20, 2018
1 parent 417956d commit b629c0b
Show file tree
Hide file tree
Showing 16 changed files with 82 additions and 293 deletions.
8 changes: 8 additions & 0 deletions CONTRIBUTING.md
Expand Up @@ -3,6 +3,14 @@
We'd love to accept your patches and contributions to this project. There are
just a few small guidelines you need to follow.

## Editing files in src/crypto

The files in src/crypto are pulled from external git repositories. They are not
submoduled so that this repo can be exported as an Arduino library. If you want
to modify prng.*, modify it directly in this repo. If you want to modify other
file either modify them using pull_crypto.sh, or modify them in the repos they
are pulled from.

## Contributor License Agreement

Contributions to this project must be accompanied by a Contributor License
Expand Down
81 changes: 0 additions & 81 deletions jwt/compile.sh

This file was deleted.

134 changes: 0 additions & 134 deletions jwt/jwt.cpp

This file was deleted.

24 changes: 0 additions & 24 deletions jwt/jwt.h

This file was deleted.

26 changes: 0 additions & 26 deletions jwt/prng.c

This file was deleted.

24 changes: 0 additions & 24 deletions jwt/prng.h

This file was deleted.

62 changes: 62 additions & 0 deletions pull_crypto.sh
@@ -0,0 +1,62 @@
#!/bin/bash
#******************************************************************************
# Copyright 2018 Google
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#****************************************************************************


# This script pulls the latest source files from github into the jwt/crypto
# folder. Run it from it's directory to get the latest files.

# Make temp directory, cd into it.
mkdir tmp
cd tmp

# Clone ecc libraries.
git clone https://github.com/cirvladimir/ecc-light-certificate.git
git clone https://github.com/CSSHL/ESP8266-Arduino-cryptolibs.git

# cd out of tmp.
cd ..

# Copy sources into jwt folder.
cp tmp/ESP8266-Arduino-cryptolibs/sha256/sha256.cpp src/crypto/sha256.cpp
cp tmp/ESP8266-Arduino-cryptolibs/sha256/sha256.h src/crypto/sha256.h
cp tmp/ecc-light-certificate/ecc/curve-params/secp256r1.c src/crypto/secp256r1.cpp
cp tmp/ecc-light-certificate/ecc/ecc.c src/crypto/ecc.cpp
cp tmp/ecc-light-certificate/ecc/ecc.h src/crypto/ecc.h
cp tmp/ecc-light-certificate/ecc/ecdsa.c src/crypto/ecdsa.cpp
cp tmp/ecc-light-certificate/ecc/ecdsa.h src/crypto/ecdsa.h
cp tmp/ecc-light-certificate/ecc/nn.c src/crypto/nn.cpp
cp tmp/ecc-light-certificate/ecc/nn.h src/crypto/nn.h

# Remove unnecessary sha library.
sed -i '/#include "sha2.h"/d' src/crypto/ecdsa.h
# Add some defines since we're not using make.
sed -i '1i#define SHA256_DIGEST_LENGTH 32' src/crypto/ecdsa.h
sed -i '1i#define THIRTYTWO_BIT_PROCESSOR' src/crypto/nn.h
sed -i '1i#define SECP256R1' src/crypto/nn.h

# Change string.h to String.h
for f in src/crypto/ecdsa.cpp src/crypto/nn.cpp src/crypto/secp256r1.cpp src/crypto/sha256.cpp
do
sed -i 's/#include <string.h>/#include <String.h>/' $f
done

# Add a do not edit comment.
for f in src/crypto/sha256.cpp src/crypto/sha256.h src/crypto/secp256r1.cpp src/crypto/ecc.cpp src/crypto/ecc.h src/crypto/ecdsa.cpp src/crypto/ecdsa.h src/crypto/nn.cpp src/crypto/nn.h
do
sed -i '1i// AUTOGENERATED, DO NOT EDIT. See CONTRIBUTING.md for instructions.' $f
done

rm -rf tmp
1 change: 1 addition & 0 deletions src/crypto/ecc.cpp
@@ -1,3 +1,4 @@
// AUTOGENERATED, DO NOT EDIT. See CONTRIBUTING.md for instructions.
/**
* \addtogroup ecc
*
Expand Down
1 change: 1 addition & 0 deletions src/crypto/ecc.h
@@ -1,3 +1,4 @@
// AUTOGENERATED, DO NOT EDIT. See CONTRIBUTING.md for instructions.
/**
* \defgroup ecc Elliptic Curve Point Arithmetic
*
Expand Down
1 change: 1 addition & 0 deletions src/crypto/ecdsa.cpp
@@ -1,3 +1,4 @@
// AUTOGENERATED, DO NOT EDIT. See CONTRIBUTING.md for instructions.
/**
* \addtogroup ecdsa
*
Expand Down

0 comments on commit b629c0b

Please sign in to comment.