Const correct SSL{_CTX}_get_ciphers calls

Fix callers within the library that need const.

Bug: 550501994
Change-Id: I164f7bc561cc11dc87455ff0f0f7afe06a6a6964
Reviewed-on: https://boringssl-review.googlesource.com/c/boringssl/+/101747
Presubmit-BoringSSL-Verified: boringssl-scoped@luci-project-accounts.iam.gserviceaccount.com <boringssl-scoped@luci-project-accounts.iam.gserviceaccount.com>
Auto-Submit: Lily Chen <chlily@google.com>
Reviewed-by: David Benjamin <davidben@google.com>
Commit-Queue: David Benjamin <davidben@google.com>
diff --git a/include/openssl/ssl.h b/include/openssl/ssl.h
index f0b3e43..75de357 100644
--- a/include/openssl/ssl.h
+++ b/include/openssl/ssl.h
@@ -1753,6 +1753,7 @@
 
 // SSL_CTX_get_ciphers returns the cipher list for `ctx`, in order of
 // preference.
+// TODO(crbug.com/550501994): This should return a const pointer.
 OPENSSL_EXPORT STACK_OF(SSL_CIPHER) *SSL_CTX_get_ciphers(const SSL_CTX *ctx);
 
 // SSL_CTX_cipher_in_group returns one if the `i`th cipher (see
@@ -1761,6 +1762,7 @@
 OPENSSL_EXPORT int SSL_CTX_cipher_in_group(const SSL_CTX *ctx, size_t i);
 
 // SSL_get_ciphers returns the cipher list for `ssl`, in order of preference.
+// TODO(crbug.com/550501994): This should return a const pointer.
 OPENSSL_EXPORT STACK_OF(SSL_CIPHER) *SSL_get_ciphers(const SSL *ssl);
 
 
diff --git a/ssl/ssl_lib.cc b/ssl/ssl_lib.cc
index fd526a6..ff885c9 100644
--- a/ssl/ssl_lib.cc
+++ b/ssl/ssl_lib.cc
@@ -2177,8 +2177,9 @@
     return nullptr;
   }
 
-  STACK_OF(SSL_CIPHER) *sk = SSL_get_ciphers(ssl);
-  if (sk == nullptr || n < 0 || (size_t)n >= sk_SSL_CIPHER_num(sk)) {
+  const STACK_OF(SSL_CIPHER) *sk = SSL_get_ciphers(ssl);
+  if (sk == nullptr || n < 0 ||
+      static_cast<size_t>(n) >= sk_SSL_CIPHER_num(sk)) {
     return nullptr;
   }
 
diff --git a/tool/ciphers.cc b/tool/ciphers.cc
index 77273ba..f5f4057 100644
--- a/tool/ciphers.cc
+++ b/tool/ciphers.cc
@@ -44,7 +44,7 @@
     return false;
   }
 
-  STACK_OF(SSL_CIPHER) *ciphers = SSL_CTX_get_ciphers(ctx.get());
+  const STACK_OF(SSL_CIPHER) *ciphers = SSL_CTX_get_ciphers(ctx.get());
 
   bool last_in_group = false;
   for (size_t i = 0; i < sk_SSL_CIPHER_num(ciphers); i++) {