Skip to content

Commit

Permalink
sec: rename secret content type
Browse files Browse the repository at this point in the history
  • Loading branch information
pulsejet committed Jan 17, 2025
1 parent 9dd509d commit f54d9a6
Show file tree
Hide file tree
Showing 6 changed files with 7 additions and 7 deletions.
2 changes: 1 addition & 1 deletion std/ndn/constants.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ const (
ContentTypeLink ContentType = 1
ContentTypeKey ContentType = 2
ContentTypeNack ContentType = 3
ContentTypeSecret ContentType = 9
ContentTypeSigKey ContentType = 9
)

// SigType represents the type of signature.
Expand Down
2 changes: 1 addition & 1 deletion std/security/certificate.go
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ func getPubKey(data ndn.Data) ([]byte, enc.Name, error) {
return nil, nil, err
}
return pub, keyName, nil
case ndn.ContentTypeSecret:
case ndn.ContentTypeSigKey:
// Content is private key, parse the signer
signer, err := sig.UnmarshalSecret(data)
if err != nil {
Expand Down
2 changes: 1 addition & 1 deletion std/security/decode_file.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ func DecodeFile(content []byte) (signers []ndn.Signer, certs [][]byte, err error
switch *data.ContentType() {
case ndn.ContentTypeKey: // cert
certs = append(certs, wire)
case ndn.ContentTypeSecret: // key
case ndn.ContentTypeSigKey: // key
key, err := sig.UnmarshalSecret(data)
if err != nil || key == nil {
log.Warn(nil, "Failed to decode key", "name", data.Name(), "error", err)
Expand Down
2 changes: 1 addition & 1 deletion std/security/rfc7468.go
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ func PemEncode(raw []byte) ([]byte, error) {
switch *data.ContentType() {
case ndn.ContentTypeKey:
pemType = PEM_TYPE_CERT
case ndn.ContentTypeSecret:
case ndn.ContentTypeSigKey:
pemType = PEM_TYPE_SECRET
default:
return nil, errors.New("unsupported content type")
Expand Down
4 changes: 2 additions & 2 deletions std/security/signer/marshal.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ func MarshalSecret(key ndn.Signer) (enc.Wire, error) {

// Encode key data packet
cfg := &ndn.DataConfig{
ContentType: utils.IdPtr(ndn.ContentTypeSecret),
ContentType: utils.IdPtr(ndn.ContentTypeSigKey),
}
data, err := spec.Spec{}.MakeData(name, cfg, enc.Wire{sk}, key)
if err != nil {
Expand All @@ -52,7 +52,7 @@ func MarshalSecret(key ndn.Signer) (enc.Wire, error) {
// UnmarshalSecret decodes a signed NDN Data packet to a key secret.
func UnmarshalSecret(data ndn.Data) (ndn.Signer, error) {
// Check data content type
if data.ContentType() == nil || *data.ContentType() != ndn.ContentTypeSecret {
if data.ContentType() == nil || *data.ContentType() != ndn.ContentTypeSigKey {
return nil, ndn.ErrInvalidValue{Item: "content type"}
}

Expand Down
2 changes: 1 addition & 1 deletion std/security/signer/marshal_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ func TestMarshalSecret(t *testing.T) {
// check output data
data, _, err := spec.Spec{}.ReadData(enc.NewWireReader(wire))
require.NoError(t, err)
require.Equal(t, ndn.ContentTypeSecret, *data.ContentType())
require.Equal(t, ndn.ContentTypeSigKey, *data.ContentType())
require.Equal(t, RSA_KEY_NAME, data.Name())
require.Equal(t, secret, data.Content().Join())
}
Expand Down

0 comments on commit f54d9a6

Please sign in to comment.