Skip to content

Commit 901cf0f

Browse files
authored
Merge pull request #4 from automata-network/docs
Update license and add docs
2 parents 3531d34 + 0b943bf commit 901cf0f

13 files changed

+712
-18
lines changed

LICENSE

Lines changed: 674 additions & 0 deletions
Large diffs are not rendered by default.

src/AndroidSafetyNet.sol

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// SPDX-License-Identifier: MIT
1+
// SPDX-License-Identifier: GPL-3.0
22
pragma solidity ^0.8.0;
33

44
import "./AttestationVerificationBase.sol";

src/AttestationVerificationBase.sol

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// SPDX-License-Identifier: MIT
1+
// SPDX-License-Identifier: GPL-3.0
22
pragma solidity ^0.8.0;
33

44
import {ISigVerifyLib} from "./utils/interfaces/ISigVerifyLib.sol";

src/WindowsTPM.sol

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// SPDX-License-Identifier: MIT
1+
// SPDX-License-Identifier: GPL-3.0
22
pragma solidity ^0.8.0;
33

44
import "./utils/SHA1.sol";

src/Yubikey.sol

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// SPDX-License-Identifier: MIT
1+
// SPDX-License-Identifier: GPL-3.0
22
pragma solidity ^0.8.0;
33

44
import "./AttestationVerificationBase.sol";

src/utils/Asn1Decode.sol

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
1-
// SPDX-License-Identifier: MIT
2-
// Original source: https://github.com/JonahGroendal/asn1-decode
1+
// SPDX-License-Identifier: Apache-2.0
32
pragma solidity ^0.8.0;
43

54
// Referenced From PufferFinance/rave - Apache-2.0 license

src/utils/CertInfoParser.sol

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,11 @@
1-
//SPDX-License-Identifier: MIT
1+
// SPDX-License-Identifier: GPL-3.0
22
pragma solidity ^0.8.0;
33

44
import "./BytesUtils.sol";
55

6+
// Library for parsing certInfo, which is a part of Windows TPM attestation
7+
// The spec is defined in the 10.12.8 section of the document: https://trustedcomputinggroup.org/wp-content/uploads/TPM-Rev-2.0-Part-2-Structures-01.38.pdf
8+
69
library CertInfoParser {
710
struct QualifiedSigner {
811
uint16 size;
@@ -16,16 +19,16 @@ library CertInfoParser {
1619

1720
struct CertInfo {
1821
bytes raw;
19-
bytes magic;
20-
bytes2 certInfoType;
21-
QualifiedSigner qualifiedSigner; // TPM2B_NAME
22-
ExtraData extraData; // TPM2B_DATA
22+
bytes magic; // TPM_GENERATED, the indication that this structure was created by a TPM (always TPM_GENERATED_VALUE)
23+
bytes2 certInfoType; // TPMI_ST_ATTEST, type of the attestation structure
24+
QualifiedSigner qualifiedSigner; // TPM2B_NAME, qualified Name of the signing key
25+
ExtraData extraData; // TPM2B_DATA, external information supplied by caller
2326
bytes8 clock;
2427
bytes4 resetCount;
2528
bytes4 restartCount;
2629
bytes1 safe;
27-
bytes8 firmwareVersion;
28-
bytes attestedField;
30+
bytes8 firmwareVersion; // TPM-vendor-specific value identifying the version number of the firmware
31+
bytes attestedField; // The type-specific attestation information
2932
}
3033

3134
function parseCertInfo(bytes memory input) internal pure returns (CertInfo memory certInfo) {

src/utils/DerParser.sol

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,14 @@
1-
// SPDX-License-Identifier: MIT
1+
// SPDX-License-Identifier: GPL-3.0
22
pragma solidity ^0.8.0;
33

44
import "./interfaces/IDerParser.sol";
55
import "./Asn1Decode.sol";
66
import "./X509DateUtils.sol";
77
import "./BytesUtils.sol";
88

9+
// Library for parsing DER-encoded X.509 certificates
10+
// NOTE: This library is not complete, it only supports parsing the fields we need for verifying the attestation
11+
912
contract DerParser is IDerParser {
1013
using Asn1Decode for bytes;
1114
using NodePtr for uint256;

src/utils/RsaVerify.sol

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import "./SHA1.sol";
66

77
// Referenced from adria0/SolRsaVerify - GPL-3.0 license
88
// https://github.com/adria0/SolRsaVerify/blob/master/src/RsaVerify.sol
9+
// Added PKCSv1.5 SHA1 verification
910

1011
/*
1112
Copyright 2016, Adrià Massanet

src/utils/SigVerifyLib.sol

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// SPDX-License-Identifier: MIT
1+
// SPDX-License-Identifier: GPL-3.0
22
pragma solidity ^0.8.0;
33

44
import "p256-verifier/P256.sol";
@@ -7,6 +7,12 @@ import "./interfaces/ISigVerifyLib.sol";
77
import "./RsaVerify.sol";
88
import "./BytesUtils.sol";
99

10+
// Library for verifying signatures
11+
// Supports verifying signatures with the following algorithms:
12+
// - RS256
13+
// - ES256
14+
// - RS1
15+
1016
contract SigVerifyLib is ISigVerifyLib {
1117
using BytesUtils for bytes;
1218

src/utils/X509DateUtils.sol

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,16 @@
1-
// SPDX-License-Identifier: MIT
1+
// SPDX-License-Identifier: GPL-3.0
22

33
pragma solidity ^0.8.0;
44

5+
// Library for parsing the date fields in X.509 certificates
6+
57
library X509DateUtils {
8+
9+
/*
10+
* @dev Convert a DER-encoded time to a unix timestamp
11+
* @param x509Time The DER-encoded time
12+
* @return The unix timestamp
13+
*/
614
function toTimestamp(bytes memory x509Time) internal pure returns (uint256) {
715
uint16 yrs;
816
uint8 mnths;

src/utils/interfaces/IDerParser.sol

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
//SPDX-License-Identifier: MIT
1+
// SPDX-License-Identifier: GPL-3.0
22
pragma solidity >=0.8.0;
33

44
interface IDerParser {

src/utils/interfaces/ISigVerifyLib.sol

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
//SPDX-License-Identifier: MIT
1+
// SPDX-License-Identifier: GPL-3.0
22
pragma solidity >=0.8.0;
33

44
interface ISigVerifyLib {

0 commit comments

Comments
 (0)