Skip to content

Conversation

oncilla
Copy link
Contributor

@oncilla oncilla commented Oct 7, 2019

Adds:

  • support for generating public keys for all available private keys.

Also:

  • fixes license in priv.go

This change is Reviewable

Adds:
- support for generating public keys for all available private keys.

Also:
- fixes license in priv.go
@oncilla oncilla marked this pull request as ready for review October 7, 2019 15:01
@oncilla oncilla requested a review from scrye October 7, 2019 15:02
@oncilla oncilla added c/CPPKI SCION Control-plane PKI c/tooling SCION network tools labels Oct 7, 2019
@oncilla oncilla added this to the Q4S1 milestone Oct 7, 2019
Copy link
Contributor

@scrye scrye left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewed 6 of 6 files at r1.
Reviewable status: all files reviewed, 4 unresolved discussions (waiting on @oncilla)


go/lib/scrypto/asym.go, line 82 at r1 (raw file):

		var privKeyFixed, pubKey [32]byte
		copy(privKeyFixed[:], privKey)
		curve25519.ScalarBaseMult(&pubKey, &privKeyFixed)

Is the endianness here correct when these values are loaded from files? I think we use little endian everywhere, but just want to double check it with you.


go/tools/scion-pki/internal/v2/keys/pub.go, line 61 at r1 (raw file):

				return nil, serrors.WrapStr("unable to load private keys for AS", err, "ia", ia)
			}
			if len(keys) > 0 {

Can drop the if, default val is nil if there are no keys.


go/tools/scion-pki/internal/v2/keys/pub.go, line 91 at r1 (raw file):

		var keys []keyconf.Key
		for _, privKey := range privKeys {
			key := privKey

This shallow copy is dangerous; if key.Bytes mutates prior to the assignment below, privKey.Bytes is also affected. I think implementing a proper Copy is safer (it also signals to someone reading the code that everything is safe; right now, I needed to go within keyconf.Key to reason what is copied by reference/pointer, and what is copied by value).


go/tools/scion-pki/internal/v2/keys/pub.go, line 131 at r1 (raw file):

		return keyconf.Key{}, serrors.WrapStr("unable to read file", err)
	}
	block, _ := pem.Decode(raw)

keyconf.KeyFromPEM would panic on block == nil, but that can be returned by pem.Decode if the input is garbage.

Copy link
Contributor Author

@oncilla oncilla left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewable status: all files reviewed, 4 unresolved discussions (waiting on @scrye)


go/lib/scrypto/asym.go, line 82 at r1 (raw file):

Previously, scrye (Sergiu Costea) wrote…

Is the endianness here correct when these values are loaded from files? I think we use little endian everywhere, but just want to double check it with you.

It is, yes.
But it is a bit awkward, I agree.


go/tools/scion-pki/internal/v2/keys/pub.go, line 61 at r1 (raw file):

Previously, scrye (Sergiu Costea) wrote…

Can drop the if, default val is nil if there are no keys.

True, but I wanted to avoid creating superfluous directories.


go/tools/scion-pki/internal/v2/keys/pub.go, line 91 at r1 (raw file):

Previously, scrye (Sergiu Costea) wrote…

This shallow copy is dangerous; if key.Bytes mutates prior to the assignment below, privKey.Bytes is also affected. I think implementing a proper Copy is safer (it also signals to someone reading the code that everything is safe; right now, I needed to go within keyconf.Key to reason what is copied by reference/pointer, and what is copied by value).

Done.


go/tools/scion-pki/internal/v2/keys/pub.go, line 131 at r1 (raw file):

Previously, scrye (Sergiu Costea) wrote…

keyconf.KeyFromPEM would panic on block == nil, but that can be returned by pem.Decode if the input is garbage.

Good catch!

Copy link
Contributor

@scrye scrye left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

:lgtm:

Reviewed 1 of 1 files at r2.
Reviewable status: :shipit: complete! all files reviewed, all discussions resolved

@oncilla oncilla merged commit 5155cad into scionproto:master Oct 7, 2019
@oncilla oncilla deleted the pub-spki-pub branch August 7, 2020 12:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
c/CPPKI SCION Control-plane PKI c/tooling SCION network tools
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants