Skip to content

Commit b39842b

Browse files
committed
refactor(client): Use go default tls cipher suites
Signed-off-by: Pierre-Henri Symoneaux <[email protected]>
1 parent dc55d68 commit b39842b

File tree

3 files changed

+22
-24
lines changed

3 files changed

+22
-24
lines changed

kmipclient/client.go

+20-22
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,26 @@ type opts struct {
3333
func (o *opts) tlsConfig() (*tls.Config, error) {
3434
cfg := o.tlsCfg
3535
if cfg == nil {
36-
cfg = &tls.Config{}
36+
cfg = &tls.Config{
37+
MinVersion: tls.VersionTLS12, // As required by KMIP 1.4 spec
38+
39+
// // TODO: Make cipher suites configurable and do not add by default legacy ones
40+
// CipherSuites: []uint16{
41+
// // Mandatory support as per KMIP 1.4 spec
42+
// // tls.TLS_RSA_WITH_AES_256_CBC_SHA256, // Not supported in Go
43+
// tls.TLS_RSA_WITH_AES_128_CBC_SHA256, // insecure
44+
45+
// // Optional support as per KMIP 1.4 spec
46+
// tls.TLS_ECDHE_ECDSA_WITH_AES_128_CBC_SHA,
47+
// tls.TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256,
48+
// tls.TLS_ECDHE_ECDSA_WITH_AES_256_GCM_SHA384,
49+
// tls.TLS_RSA_WITH_AES_128_CBC_SHA, // insecure
50+
// tls.TLS_RSA_WITH_AES_256_CBC_SHA, // insecure
51+
// tls.TLS_ECDHE_ECDSA_WITH_AES_128_CBC_SHA256, // insecure
52+
// tls.TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA, // insecure
53+
// tls.TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256, // insecure
54+
// },
55+
}
3756
}
3857
if cfg.RootCAs == nil {
3958
if len(o.rootCAs) > 0 {
@@ -52,27 +71,6 @@ func (o *opts) tlsConfig() (*tls.Config, error) {
5271
if cfg.ServerName == "" {
5372
cfg.ServerName = o.serverName
5473
}
55-
if cfg.MinVersion == 0 {
56-
cfg.MinVersion = tls.VersionTLS12 // As required by KMIP 1.4 spec
57-
}
58-
if len(cfg.CipherSuites) == 0 {
59-
cfg.CipherSuites = []uint16{
60-
// Mandatory support as per KMIP 1.4 spec
61-
// tls.TLS_RSA_WITH_AES_256_CBC_SHA256, // Not supported in Go
62-
tls.TLS_RSA_WITH_AES_128_CBC_SHA256,
63-
64-
// Optional support as per KMIP 1.4 spec
65-
tls.TLS_RSA_WITH_AES_128_CBC_SHA,
66-
tls.TLS_RSA_WITH_AES_256_CBC_SHA,
67-
tls.TLS_ECDHE_ECDSA_WITH_AES_128_CBC_SHA,
68-
tls.TLS_ECDHE_ECDSA_WITH_AES_128_CBC_SHA256,
69-
tls.TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA,
70-
tls.TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256,
71-
tls.TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256,
72-
tls.TLS_ECDHE_ECDSA_WITH_AES_256_GCM_SHA384,
73-
tls.TLS_ECDHE_ECDSA_WITH_AES_128_CBC_SHA256,
74-
}
75-
}
7674
return cfg, nil
7775
}
7876

ttlv/encoder.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -293,7 +293,7 @@ func encodeFunc(ty reflect.Type) func(*Encoder, int, reflect.Value) {
293293
}
294294
case reflect.Int64:
295295
return func(e *Encoder, tag int, v reflect.Value) {
296-
e.LongInteger(tag, int64(v.Int()))
296+
e.LongInteger(tag, v.Int())
297297
}
298298
case reflect.Bool:
299299
return func(e *Encoder, tag int, v reflect.Value) {

ttlv/encoding_ttlv.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ func (enc *ttlvWriter) BigInteger(tag int, value *big.Int) {
8989

9090
func (enc *ttlvWriter) Enum(enumtag, tag int, value uint32) {
9191
enc.encodeAppend(tag, TypeEnumeration, 4, func(b []byte) []byte {
92-
b = binary.BigEndian.AppendUint32(b, uint32(value))
92+
b = binary.BigEndian.AppendUint32(b, value)
9393
return append(b, 0, 0, 0, 0)
9494
})
9595
}

0 commit comments

Comments
 (0)