Skip to content

Commit

Permalink
Squashed commit of the following:
Browse files Browse the repository at this point in the history
commit 2862807
Author: Junjie Gao <junjiegao@microsoft.com>
Date:   Wed Jan 31 15:21:55 2024 +0800

    feat: ber to der convertor (notaryproject#11)

    Signed-off-by: Junjie Gao <junjiegao@microsoft.com>

commit a373599
Author: Patrick Zheng <patrickzheng@microsoft.com>
Date:   Mon Jan 22 16:37:33 2024 +0800

    ci: add MAKEFILE and build workflow to the repo (notaryproject#19)

    Signed-off-by: Patrick Zheng <patrickzheng@microsoft.com>

commit 6fa8c7f
Author: Patrick Zheng <patrickzheng@microsoft.com>
Date:   Mon Jan 22 16:36:50 2024 +0800

    ci: add dependabot (notaryproject#16)

    Signed-off-by: Patrick Zheng <patrickzheng@microsoft.com>

commit bdae447
Author: Patrick Zheng <patrickzheng@microsoft.com>
Date:   Mon Jan 22 16:36:24 2024 +0800

    ci: add code coverage check (notaryproject#15)

    Signed-off-by: Patrick Zheng <patrickzheng@microsoft.com>

commit 4cc6846
Author: Patrick Zheng <patrickzheng@microsoft.com>
Date:   Mon Jan 22 16:35:54 2024 +0800

    ci: add license checker to the repo (notaryproject#13)

    Signed-off-by: Patrick Zheng <patrickzheng@microsoft.com>

commit a27c098
Author: Yi Zha <yizha1@microsoft.com>
Date:   Thu Jan 18 10:02:22 2024 +0800

    chore: add CODEOWNERS and MAINTAINERS file (notaryproject#12)

    Resolve notaryproject#2

    Signed-off-by: Yi Zha <yizha1@microsoft.com>

Signed-off-by: Junjie Gao <junjiegao@microsoft.com>
  • Loading branch information
JeyJeyGao committed Jan 31, 2024
1 parent 5061c10 commit 948d2f5
Show file tree
Hide file tree
Showing 10 changed files with 205 additions and 6 deletions.
18 changes: 18 additions & 0 deletions .github/.codecov.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# Copyright The Notary Project Authors.
# 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.

coverage:
status:
project:
default:
target: 80%
23 changes: 23 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# Copyright The Notary Project Authors.
# 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.

version: 2
updates:
- package-ecosystem: "gomod"
directory: "/"
schedule:
interval: "weekly"
- package-ecosystem: "github-actions"
directory: "/"
schedule:
interval: "weekly"
44 changes: 44 additions & 0 deletions .github/licenserc.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
# Copyright The Notary Project Authors.
# 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.

header:
license:
spdx-id: Apache-2.0
content: |
Copyright The Notary Project Authors.
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.
paths-ignore:
- '**/*.md'
- 'CODEOWNERS'
- 'LICENSE'
- 'MAINTAINERS'
- 'go.mod'
- 'go.sum'
- '**/testdata/**'

comment: on-failure

dependency:
files:
- go.mod
24 changes: 24 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
# Copyright The Notary Project Authors.
# 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.

name: build

on:
push:
branches: main
pull_request:
branches: main

jobs:
build:
uses: notaryproject/notation-core-go/.github/workflows/reusable-build.yml@main
28 changes: 28 additions & 0 deletions .github/workflows/license-checker.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
# Copyright The Notary Project Authors.
# 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.

name: License Checker

on:
push:
branches: main
pull_request:
branches: main

permissions:
contents: write
pull-requests: write

jobs:
check-license:
uses: notaryproject/notation-core-go/.github/workflows/reusable-license-checker.yml@main
3 changes: 3 additions & 0 deletions CODEOWNERS
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# Repo-Level Owners (in alphabetical order)
# Note: This is only for the notaryproject/tspclient-go repo
* @JeyJeyGao @shizhMSFT @Two-Hearts @notaryproject/notaryproject-org-maintainers
15 changes: 15 additions & 0 deletions MAINTAINERS
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# Org-Level Maintainers (in alphabetical order)
# Pattern: [First Name] [Last Name] <[Email Address]> ([GitHub Handle])
Justin Cormack <justin.cormack@docker.com> (@justincormack)
Niaz Khan <niazfk@amazon.com> (@niazfk)
Pritesh Bandi <priteshbandi@gmail.com> (@priteshbandi)
Shiwei Zhang <shizh@microsoft.com> (@shizhMSFT)
Steve Lasker <StevenLasker@hotmail.com> (@stevelasker)
Toddy Mladenov <toddysm@gmail.com> (@toddysm)

# Repo-Level Maintainers (in alphabetical order)
# Pattern: [First Name] [Last Name] <[Email Address]> ([GitHub Handle])
# Note: This is for the notaryproject/tspclient-go repo
Junjie Gao <junjiegao@microsoft.com> (@JeyJeyGao)
Patrick Zheng <patrickzheng@microsoft.com> (@Two-Hearts)
Shiwei Zhang <shizh@microsoft.com> (@shizhMSFT)
36 changes: 36 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
# Copyright The Notary Project Authors.
# 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.

.PHONY: help
help:
@grep -E '^[a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) | sort | awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m%-25s\033[0m %s\n", $$1, $$2}'

.PHONY: all
all: test

.PHONY: test
test: check-line-endings ## run unit tests
go test -race -v -coverprofile=coverage.txt -covermode=atomic ./...

.PHONY: clean
clean:
git status --ignored --short | grep '^!! ' | sed 's/!! //' | xargs rm -rf

.PHONY: check-line-endings
check-line-endings: ## check line endings
! find . -name "*.go" -type f -exec file "{}" ";" | grep CRLF
! find scripts -name "*.sh" -type f -exec file "{}" ";" | grep CRLF

.PHONY: fix-line-endings
fix-line-endings: ## fix line endings
find . -type f -name "*.go" -exec sed -i -e "s/\r//g" {} +
10 changes: 8 additions & 2 deletions internal/encoding/asn1/ber/ber.go
Original file line number Diff line number Diff line change
Expand Up @@ -115,8 +115,12 @@ func decode(r []byte) ([]value, error) {

// start depth-first decoding with stack
contructedStack := []*constructed{rootConstructed}
for len(contructedStack) > 0 {
for {
stackLen := len(contructedStack)
if stackLen == 0 {
break
}

// top
node := contructedStack[stackLen-1]

Expand Down Expand Up @@ -259,7 +263,9 @@ func decodeLength(r []byte) (int, []byte, error) {
return 0, nil, asn1.SyntaxError{Msg: "decoding BER length octets: short form length octets value should be less or equal to the subsequent octets length"}
}
return contentLen, subsequentOctets, nil
} else if b == 0x80 {
}

if b == 0x80 {
// Indefinite-length method is not supported.
// Reference: ISO/IEC 8825-1: 8.1.3.6.1
return 0, nil, asn1.StructuralError{Msg: "decoding BER length octets: indefinite length not supported"}
Expand Down
10 changes: 6 additions & 4 deletions internal/encoding/asn1/ber/common.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,9 @@ type writer interface {
}

// encodeLength encodes length octets in DER.
// Reference: ISO/IEC 8825-1: 10.1
// Reference: https://learn.microsoft.com/windows/win32/seccertenroll/about-encoded-length-and-value-bytes
// Reference:
// - ISO/IEC 8825-1: 10.1
// - https://learn.microsoft.com/windows/win32/seccertenroll/about-encoded-length-and-value-bytes
func encodeLength(w io.ByteWriter, length int) error {
// DER restriction: short form must be used for length less than 128
if length < 0x80 {
Expand All @@ -46,8 +47,9 @@ func encodeLength(w io.ByteWriter, length int) error {

// encodedLengthSize gives the number of octets used for encoding the length
// in DER.
// Reference: ISO/IEC 8825-1: 10.1
// Reference: https://learn.microsoft.com/windows/win32/seccertenroll/about-encoded-length-and-value-bytes
// Reference:
// - ISO/IEC 8825-1: 10.1
// - https://learn.microsoft.com/windows/win32/seccertenroll/about-encoded-length-and-value-bytes
func encodedLengthSize(length int) int {
if length < 0x80 {
return 1
Expand Down

0 comments on commit 948d2f5

Please sign in to comment.