summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorjsing <>2019-11-02 13:56:17 +0000
committerjsing <>2019-11-02 13:56:17 +0000
commit760ebfaeaec25b212c2db98a19207c3d8bb86389 (patch)
treee0597fc1fb4e5b269c4843efb8152e6e601a5eaa
parent719154ccb7bebf2723783eca89365034db24821f (diff)
downloadopenbsd-760ebfaeaec25b212c2db98a19207c3d8bb86389.tar.gz
openbsd-760ebfaeaec25b212c2db98a19207c3d8bb86389.tar.bz2
openbsd-760ebfaeaec25b212c2db98a19207c3d8bb86389.zip
Add tls_conn_cipher_strength() to gotls regress.
-rw-r--r--src/regress/lib/libtls/gotls/tls.go10
-rw-r--r--src/regress/lib/libtls/gotls/tls_test.go12
2 files changed, 20 insertions, 2 deletions
diff --git a/src/regress/lib/libtls/gotls/tls.go b/src/regress/lib/libtls/gotls/tls.go
index be75e71f4f..dbd3b717b0 100644
--- a/src/regress/lib/libtls/gotls/tls.go
+++ b/src/regress/lib/libtls/gotls/tls.go
@@ -256,6 +256,16 @@ func (t *TLS) ConnCipher() (string, error) {
256 return C.GoString(cipher), nil 256 return C.GoString(cipher), nil
257} 257}
258 258
259// ConnCipherStrength returns the strength in bits for the symmetric
260// cipher that is used for the connection.
261func (t *TLS) ConnCipherStrength() (int, error) {
262 strength := C.tls_conn_cipher_strength(t.ctx)
263 if strength == 0 {
264 return 0, errors.New("no connection cipher strength")
265 }
266 return int(strength), nil
267}
268
259// Connect attempts to establish an TLS connection to the specified host on 269// Connect attempts to establish an TLS connection to the specified host on
260// the given port. The host may optionally contain a colon separated port 270// the given port. The host may optionally contain a colon separated port
261// value if the port string is specified as an empty string. 271// value if the port string is specified as an empty string.
diff --git a/src/regress/lib/libtls/gotls/tls_test.go b/src/regress/lib/libtls/gotls/tls_test.go
index 077dd86e82..1a9f62eff8 100644
--- a/src/regress/lib/libtls/gotls/tls_test.go
+++ b/src/regress/lib/libtls/gotls/tls_test.go
@@ -336,6 +336,9 @@ func TestTLSInfo(t *testing.T) {
336 if _, err := tls.ConnCipher(); err == nil { 336 if _, err := tls.ConnCipher(); err == nil {
337 t.Error("ConnCipher() return nil error, want error") 337 t.Error("ConnCipher() return nil error, want error")
338 } 338 }
339 if _, err := tls.ConnCipherStrength(); err == nil {
340 t.Error("ConnCipherStrength() return nil error, want error")
341 }
339 342
340 if got, want := tls.PeerCertProvided(), false; got != want { 343 if got, want := tls.PeerCertProvided(), false; got != want {
341 t.Errorf("PeerCertProvided() = %v, want %v", got, want) 344 t.Errorf("PeerCertProvided() = %v, want %v", got, want)
@@ -368,15 +371,20 @@ func TestTLSInfo(t *testing.T) {
368 } 371 }
369 372
370 if version, err := tls.ConnVersion(); err != nil { 373 if version, err := tls.ConnVersion(); err != nil {
371 t.Errorf("ConnVersion() return error: %v", err) 374 t.Errorf("ConnVersion() returned error: %v", err)
372 } else { 375 } else {
373 t.Logf("Protocol version: %v", version) 376 t.Logf("Protocol version: %v", version)
374 } 377 }
375 if cipher, err := tls.ConnCipher(); err != nil { 378 if cipher, err := tls.ConnCipher(); err != nil {
376 t.Errorf("ConnCipher() return error: %v", err) 379 t.Errorf("ConnCipher() returned error: %v", err)
377 } else { 380 } else {
378 t.Logf("Cipher: %v", cipher) 381 t.Logf("Cipher: %v", cipher)
379 } 382 }
383 if strength, err := tls.ConnCipherStrength(); err != nil {
384 t.Errorf("ConnCipherStrength() return ederror: %v", err)
385 } else {
386 t.Logf("Cipher Strength: %v bits", strength)
387 }
380 388
381 if got, want := tls.PeerCertProvided(), true; got != want { 389 if got, want := tls.PeerCertProvided(), true; got != want {
382 t.Errorf("PeerCertProvided() = %v, want %v", got, want) 390 t.Errorf("PeerCertProvided() = %v, want %v", got, want)