| 160 | } |
| 161 | |
| 162 | cc_result SSL_Init(cc_socket socket, const cc_string* host_, void** out_ctx) { |
| 163 | SSLContext* ctx; |
| 164 | char host[NATIVE_STR_LEN]; |
| 165 | String_EncodeUtf8(host, host_); |
| 166 | |
| 167 | ctx = (SSLContext*)Mem_TryAlloc(1, sizeof(SSLContext)); |
| 168 | if (!ctx) return ERR_OUT_OF_MEMORY; |
| 169 | *out_ctx = (void*)ctx; |
| 170 | |
| 171 | #if defined CC_BUILD_SYMBIAN |
| 172 | { |
| 173 | TAs[3].pkey.key.ec.curve = BR_EC_secp384r1; |
| 174 | TAs[3].pkey.key.ec.q = (unsigned char *)TA3_EC_Q; |
| 175 | TAs[3].pkey.key.ec.qlen = sizeof TA3_EC_Q; |
| 176 | |
| 177 | TAs[6].pkey.key.ec.curve = BR_EC_secp384r1; |
| 178 | TAs[6].pkey.key.ec.q = (unsigned char *)TA6_EC_Q; |
| 179 | TAs[6].pkey.key.ec.qlen = sizeof TA6_EC_Q; |
| 180 | } |
| 181 | #endif |
| 182 | |
| 183 | br_ssl_client_init_full(&ctx->sc, &ctx->xc, TAs, TAs_NUM); |
| 184 | InjectEntropy(ctx); |
| 185 | br_x509_minimal_set_time_callback(&ctx->xc, NULL, ssl_time_check_callback); |
| 186 | ctx->socket = socket; |
| 187 | |
| 188 | br_ssl_engine_set_buffer(&ctx->sc.eng, ctx->iobuf, sizeof(ctx->iobuf), 1); |
| 189 | br_ssl_client_reset(&ctx->sc, host, 0); |
| 190 | ctx->xc.vtable = &cert_verifier_vtable; |
| 191 | |
| 192 | /* Account login must be done over TLS 1.2 */ |
| 193 | if (String_CaselessEqualsConst(host_, "www.classicube.net")) { |
| 194 | br_ssl_engine_set_versions(&ctx->sc.eng, BR_TLS12, BR_TLS12); |
| 195 | } |
| 196 | |
| 197 | br_sslio_init(&ctx->ioc, &ctx->sc.eng, |
| 198 | sock_read, ctx, |
| 199 | sock_write, ctx); |
| 200 | |
| 201 | ctx->readError = 0; |
| 202 | ctx->writeError = 0; |
| 203 | |
| 204 | return 0; |
| 205 | } |
| 206 | |
| 207 | static CC_NOINLINE cc_result SSL_GetError(SSLContext* ctx) { |
| 208 | int err; |
no test coverage detected