Skip to content

Commit 58c67ea

Browse files
committed
remove everything which is not ECDSA except default values
1 parent 2460095 commit 58c67ea

File tree

2 files changed

+2
-27
lines changed

2 files changed

+2
-27
lines changed

internal/types/tls/types.go

Lines changed: 0 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@ package tls
1717
import (
1818
"crypto"
1919
"crypto/ecdsa"
20-
"crypto/rsa"
2120
"fmt"
2221
)
2322

@@ -44,25 +43,13 @@ type HashAlgorithm Enum
4443

4544
// HashAlgorithm constants from RFC 5246 s7.4.1.4.1.
4645
const (
47-
None HashAlgorithm = 0
48-
MD5 HashAlgorithm = 1
49-
SHA1 HashAlgorithm = 2
50-
SHA224 HashAlgorithm = 3
5146
SHA256 HashAlgorithm = 4
5247
SHA384 HashAlgorithm = 5
5348
SHA512 HashAlgorithm = 6
5449
)
5550

5651
func (h HashAlgorithm) String() string {
5752
switch h {
58-
case None:
59-
return "None"
60-
case MD5:
61-
return "MD5"
62-
case SHA1:
63-
return "SHA1"
64-
case SHA224:
65-
return "SHA224"
6653
case SHA256:
6754
return "SHA256"
6855
case SHA384:
@@ -80,16 +67,13 @@ type SignatureAlgorithm Enum
8067
// SignatureAlgorithm constants from RFC 5246 s7.4.1.4.1.
8168
const (
8269
Anonymous SignatureAlgorithm = 0
83-
RSA SignatureAlgorithm = 1
8470
ECDSA SignatureAlgorithm = 3
8571
)
8672

8773
func (s SignatureAlgorithm) String() string {
8874
switch s {
8975
case Anonymous:
9076
return "Anonymous"
91-
case RSA:
92-
return "RSA"
9377
case ECDSA:
9478
return "ECDSA"
9579
default:
@@ -103,8 +87,6 @@ func SignatureAlgorithmFromPubKey(k crypto.PublicKey) SignatureAlgorithm {
10387
switch k.(type) {
10488
case *ecdsa.PublicKey:
10589
return ECDSA
106-
case *rsa.PublicKey:
107-
return RSA
10890
default:
10991
return Anonymous
11092
}

internal/types/tls/types_test.go

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@ package tls
1717
import (
1818
"crypto"
1919
"crypto/ecdsa"
20-
"crypto/rsa"
2120
"testing"
2221
)
2322

@@ -26,10 +25,6 @@ func TestHashAlgorithmString(t *testing.T) {
2625
algo HashAlgorithm
2726
want string
2827
}{
29-
{None, "None"},
30-
{MD5, "MD5"},
31-
{SHA1, "SHA1"},
32-
{SHA224, "SHA224"},
3328
{SHA256, "SHA256"},
3429
{SHA384, "SHA384"},
3530
{SHA512, "SHA512"},
@@ -48,7 +43,6 @@ func TestSignatureAlgorithmString(t *testing.T) {
4843
want string
4944
}{
5045
{Anonymous, "Anonymous"},
51-
{RSA, "RSA"},
5246
{ECDSA, "ECDSA"},
5347
{99, "UNKNOWN(99)"},
5448
}
@@ -65,8 +59,8 @@ func TestDigitallySignedString(t *testing.T) {
6559
want string
6660
}{
6761
{
68-
ds: DigitallySigned{Algorithm: SignatureAndHashAlgorithm{Hash: SHA1, Signature: RSA}, Signature: []byte{0x01, 0x02}},
69-
want: "Signature: HashAlgo=SHA1 SignAlgo=RSA Value=0102",
62+
ds: DigitallySigned{Algorithm: SignatureAndHashAlgorithm{Hash: SHA256, Signature: ECDSA}, Signature: []byte{0x01, 0x02}},
63+
want: "Signature: HashAlgo=SHA256 SignAlgo=ECDSA Value=0102",
7064
},
7165
{
7266
ds: DigitallySigned{Algorithm: SignatureAndHashAlgorithm{Hash: 99, Signature: 99}, Signature: []byte{0x03, 0x04}},
@@ -87,7 +81,6 @@ func TestSignatureAlgorithm(t *testing.T) {
8781
want SignatureAlgorithm
8882
}{
8983
{name: "ECDSA", key: new(ecdsa.PublicKey), want: ECDSA},
90-
{name: "RSA", key: new(rsa.PublicKey), want: RSA},
9184
{name: "Other", key: "foo", want: Anonymous},
9285
} {
9386
if got := SignatureAlgorithmFromPubKey(test.key); got != test.want {

0 commit comments

Comments
 (0)