ssl_privkey.cc 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488
  1. /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
  2. * All rights reserved.
  3. *
  4. * This package is an SSL implementation written
  5. * by Eric Young (eay@cryptsoft.com).
  6. * The implementation was written so as to conform with Netscapes SSL.
  7. *
  8. * This library is free for commercial and non-commercial use as long as
  9. * the following conditions are aheared to. The following conditions
  10. * apply to all code found in this distribution, be it the RC4, RSA,
  11. * lhash, DES, etc., code; not just the SSL code. The SSL documentation
  12. * included with this distribution is covered by the same copyright terms
  13. * except that the holder is Tim Hudson (tjh@cryptsoft.com).
  14. *
  15. * Copyright remains Eric Young's, and as such any Copyright notices in
  16. * the code are not to be removed.
  17. * If this package is used in a product, Eric Young should be given attribution
  18. * as the author of the parts of the library used.
  19. * This can be in the form of a textual message at program startup or
  20. * in documentation (online or textual) provided with the package.
  21. *
  22. * Redistribution and use in source and binary forms, with or without
  23. * modification, are permitted provided that the following conditions
  24. * are met:
  25. * 1. Redistributions of source code must retain the copyright
  26. * notice, this list of conditions and the following disclaimer.
  27. * 2. Redistributions in binary form must reproduce the above copyright
  28. * notice, this list of conditions and the following disclaimer in the
  29. * documentation and/or other materials provided with the distribution.
  30. * 3. All advertising materials mentioning features or use of this software
  31. * must display the following acknowledgement:
  32. * "This product includes cryptographic software written by
  33. * Eric Young (eay@cryptsoft.com)"
  34. * The word 'cryptographic' can be left out if the rouines from the library
  35. * being used are not cryptographic related :-).
  36. * 4. If you include any Windows specific code (or a derivative thereof) from
  37. * the apps directory (application code) you must include an acknowledgement:
  38. * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)"
  39. *
  40. * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND
  41. * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  42. * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
  43. * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
  44. * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
  45. * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
  46. * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
  47. * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
  48. * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
  49. * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  50. * SUCH DAMAGE.
  51. *
  52. * The licence and distribution terms for any publically available version or
  53. * derivative of this code cannot be changed. i.e. this code cannot simply be
  54. * copied and put under another distribution licence
  55. * [including the GNU Public Licence.] */
  56. #include <openssl/ssl.h>
  57. #include <assert.h>
  58. #include <limits.h>
  59. #include <openssl/ec.h>
  60. #include <openssl/ec_key.h>
  61. #include <openssl/err.h>
  62. #include <openssl/evp.h>
  63. #include <openssl/mem.h>
  64. #include "internal.h"
  65. #include "../crypto/internal.h"
  66. namespace bssl {
  67. int ssl_is_key_type_supported(int key_type) {
  68. return key_type == EVP_PKEY_RSA || key_type == EVP_PKEY_EC ||
  69. key_type == EVP_PKEY_ED25519;
  70. }
  71. static int ssl_set_pkey(CERT *cert, EVP_PKEY *pkey) {
  72. if (!ssl_is_key_type_supported(pkey->type)) {
  73. OPENSSL_PUT_ERROR(SSL, SSL_R_UNKNOWN_CERTIFICATE_TYPE);
  74. return 0;
  75. }
  76. if (cert->chain != NULL &&
  77. sk_CRYPTO_BUFFER_value(cert->chain, 0) != NULL &&
  78. // Sanity-check that the private key and the certificate match.
  79. !ssl_cert_check_private_key(cert, pkey)) {
  80. return 0;
  81. }
  82. EVP_PKEY_free(cert->privatekey);
  83. EVP_PKEY_up_ref(pkey);
  84. cert->privatekey = pkey;
  85. return 1;
  86. }
  87. typedef struct {
  88. uint16_t sigalg;
  89. int pkey_type;
  90. int curve;
  91. const EVP_MD *(*digest_func)(void);
  92. char is_rsa_pss;
  93. } SSL_SIGNATURE_ALGORITHM;
  94. static const SSL_SIGNATURE_ALGORITHM kSignatureAlgorithms[] = {
  95. {SSL_SIGN_RSA_PKCS1_MD5_SHA1, EVP_PKEY_RSA, NID_undef, &EVP_md5_sha1, 0},
  96. {SSL_SIGN_RSA_PKCS1_SHA1, EVP_PKEY_RSA, NID_undef, &EVP_sha1, 0},
  97. {SSL_SIGN_RSA_PKCS1_SHA256, EVP_PKEY_RSA, NID_undef, &EVP_sha256, 0},
  98. {SSL_SIGN_RSA_PKCS1_SHA384, EVP_PKEY_RSA, NID_undef, &EVP_sha384, 0},
  99. {SSL_SIGN_RSA_PKCS1_SHA512, EVP_PKEY_RSA, NID_undef, &EVP_sha512, 0},
  100. {SSL_SIGN_RSA_PSS_SHA256, EVP_PKEY_RSA, NID_undef, &EVP_sha256, 1},
  101. {SSL_SIGN_RSA_PSS_SHA384, EVP_PKEY_RSA, NID_undef, &EVP_sha384, 1},
  102. {SSL_SIGN_RSA_PSS_SHA512, EVP_PKEY_RSA, NID_undef, &EVP_sha512, 1},
  103. {SSL_SIGN_ECDSA_SHA1, EVP_PKEY_EC, NID_undef, &EVP_sha1, 0},
  104. {SSL_SIGN_ECDSA_SECP256R1_SHA256, EVP_PKEY_EC, NID_X9_62_prime256v1,
  105. &EVP_sha256, 0},
  106. {SSL_SIGN_ECDSA_SECP384R1_SHA384, EVP_PKEY_EC, NID_secp384r1, &EVP_sha384,
  107. 0},
  108. {SSL_SIGN_ECDSA_SECP521R1_SHA512, EVP_PKEY_EC, NID_secp521r1, &EVP_sha512,
  109. 0},
  110. {SSL_SIGN_ED25519, EVP_PKEY_ED25519, NID_undef, NULL, 0},
  111. };
  112. static const SSL_SIGNATURE_ALGORITHM *get_signature_algorithm(uint16_t sigalg) {
  113. for (size_t i = 0; i < OPENSSL_ARRAY_SIZE(kSignatureAlgorithms); i++) {
  114. if (kSignatureAlgorithms[i].sigalg == sigalg) {
  115. return &kSignatureAlgorithms[i];
  116. }
  117. }
  118. return NULL;
  119. }
  120. int ssl_has_private_key(const SSL *ssl) {
  121. return ssl->cert->privatekey != NULL || ssl->cert->key_method != NULL;
  122. }
  123. static int pkey_supports_algorithm(const SSL *ssl, EVP_PKEY *pkey,
  124. uint16_t sigalg) {
  125. const SSL_SIGNATURE_ALGORITHM *alg = get_signature_algorithm(sigalg);
  126. if (alg == NULL ||
  127. EVP_PKEY_id(pkey) != alg->pkey_type) {
  128. return 0;
  129. }
  130. if (ssl_protocol_version(ssl) >= TLS1_3_VERSION) {
  131. // RSA keys may only be used with RSA-PSS.
  132. if (alg->pkey_type == EVP_PKEY_RSA && !alg->is_rsa_pss) {
  133. return 0;
  134. }
  135. // EC keys have a curve requirement.
  136. if (alg->pkey_type == EVP_PKEY_EC &&
  137. (alg->curve == NID_undef ||
  138. EC_GROUP_get_curve_name(
  139. EC_KEY_get0_group(EVP_PKEY_get0_EC_KEY(pkey))) != alg->curve)) {
  140. return 0;
  141. }
  142. }
  143. return 1;
  144. }
  145. static int setup_ctx(SSL *ssl, EVP_MD_CTX *ctx, EVP_PKEY *pkey, uint16_t sigalg,
  146. int is_verify) {
  147. if (!pkey_supports_algorithm(ssl, pkey, sigalg)) {
  148. OPENSSL_PUT_ERROR(SSL, SSL_R_WRONG_SIGNATURE_TYPE);
  149. return 0;
  150. }
  151. const SSL_SIGNATURE_ALGORITHM *alg = get_signature_algorithm(sigalg);
  152. const EVP_MD *digest = alg->digest_func != NULL ? alg->digest_func() : NULL;
  153. EVP_PKEY_CTX *pctx;
  154. if (is_verify) {
  155. if (!EVP_DigestVerifyInit(ctx, &pctx, digest, NULL, pkey)) {
  156. return 0;
  157. }
  158. } else if (!EVP_DigestSignInit(ctx, &pctx, digest, NULL, pkey)) {
  159. return 0;
  160. }
  161. if (alg->is_rsa_pss) {
  162. if (!EVP_PKEY_CTX_set_rsa_padding(pctx, RSA_PKCS1_PSS_PADDING) ||
  163. !EVP_PKEY_CTX_set_rsa_pss_saltlen(pctx, -1 /* salt len = hash len */)) {
  164. return 0;
  165. }
  166. }
  167. return 1;
  168. }
  169. enum ssl_private_key_result_t ssl_private_key_sign(
  170. SSL_HANDSHAKE *hs, uint8_t *out, size_t *out_len, size_t max_out,
  171. uint16_t sigalg, Span<const uint8_t> in) {
  172. SSL *const ssl = hs->ssl;
  173. if (ssl->cert->key_method != NULL) {
  174. enum ssl_private_key_result_t ret;
  175. if (hs->pending_private_key_op) {
  176. ret = ssl->cert->key_method->complete(ssl, out, out_len, max_out);
  177. } else {
  178. ret = ssl->cert->key_method->sign(ssl, out, out_len, max_out, sigalg,
  179. in.data(), in.size());
  180. }
  181. hs->pending_private_key_op = ret == ssl_private_key_retry;
  182. return ret;
  183. }
  184. *out_len = max_out;
  185. ScopedEVP_MD_CTX ctx;
  186. if (!setup_ctx(ssl, ctx.get(), ssl->cert->privatekey, sigalg, 0 /* sign */) ||
  187. !EVP_DigestSign(ctx.get(), out, out_len, in.data(), in.size())) {
  188. return ssl_private_key_failure;
  189. }
  190. return ssl_private_key_success;
  191. }
  192. bool ssl_public_key_verify(SSL *ssl, Span<const uint8_t> signature,
  193. uint16_t sigalg, EVP_PKEY *pkey,
  194. Span<const uint8_t> in) {
  195. ScopedEVP_MD_CTX ctx;
  196. return setup_ctx(ssl, ctx.get(), pkey, sigalg, 1 /* verify */) &&
  197. EVP_DigestVerify(ctx.get(), signature.data(), signature.size(),
  198. in.data(), in.size());
  199. }
  200. enum ssl_private_key_result_t ssl_private_key_decrypt(SSL_HANDSHAKE *hs,
  201. uint8_t *out,
  202. size_t *out_len,
  203. size_t max_out,
  204. Span<const uint8_t> in) {
  205. SSL *const ssl = hs->ssl;
  206. if (ssl->cert->key_method != NULL) {
  207. enum ssl_private_key_result_t ret;
  208. if (hs->pending_private_key_op) {
  209. ret = ssl->cert->key_method->complete(ssl, out, out_len, max_out);
  210. } else {
  211. ret = ssl->cert->key_method->decrypt(ssl, out, out_len, max_out,
  212. in.data(), in.size());
  213. }
  214. hs->pending_private_key_op = ret == ssl_private_key_retry;
  215. return ret;
  216. }
  217. RSA *rsa = EVP_PKEY_get0_RSA(ssl->cert->privatekey);
  218. if (rsa == NULL) {
  219. // Decrypt operations are only supported for RSA keys.
  220. OPENSSL_PUT_ERROR(SSL, ERR_R_INTERNAL_ERROR);
  221. return ssl_private_key_failure;
  222. }
  223. // Decrypt with no padding. PKCS#1 padding will be removed as part of the
  224. // timing-sensitive code by the caller.
  225. if (!RSA_decrypt(rsa, out_len, out, max_out, in.data(), in.size(),
  226. RSA_NO_PADDING)) {
  227. return ssl_private_key_failure;
  228. }
  229. return ssl_private_key_success;
  230. }
  231. bool ssl_private_key_supports_signature_algorithm(SSL_HANDSHAKE *hs,
  232. uint16_t sigalg) {
  233. SSL *const ssl = hs->ssl;
  234. if (!pkey_supports_algorithm(ssl, hs->local_pubkey.get(), sigalg)) {
  235. return false;
  236. }
  237. // Ensure the RSA key is large enough for the hash. RSASSA-PSS requires that
  238. // emLen be at least hLen + sLen + 2. Both hLen and sLen are the size of the
  239. // hash in TLS. Reasonable RSA key sizes are large enough for the largest
  240. // defined RSASSA-PSS algorithm, but 1024-bit RSA is slightly too small for
  241. // SHA-512. 1024-bit RSA is sometimes used for test credentials, so check the
  242. // size so that we can fall back to another algorithm in that case.
  243. const SSL_SIGNATURE_ALGORITHM *alg = get_signature_algorithm(sigalg);
  244. if (alg->is_rsa_pss && (size_t)EVP_PKEY_size(hs->local_pubkey.get()) <
  245. 2 * EVP_MD_size(alg->digest_func()) + 2) {
  246. return false;
  247. }
  248. return true;
  249. }
  250. } // namespace bssl
  251. using namespace bssl;
  252. int SSL_use_RSAPrivateKey(SSL *ssl, RSA *rsa) {
  253. if (rsa == NULL) {
  254. OPENSSL_PUT_ERROR(SSL, ERR_R_PASSED_NULL_PARAMETER);
  255. return 0;
  256. }
  257. UniquePtr<EVP_PKEY> pkey(EVP_PKEY_new());
  258. if (!pkey ||
  259. !EVP_PKEY_set1_RSA(pkey.get(), rsa)) {
  260. OPENSSL_PUT_ERROR(SSL, ERR_R_EVP_LIB);
  261. return 0;
  262. }
  263. return ssl_set_pkey(ssl->cert, pkey.get());
  264. }
  265. int SSL_use_RSAPrivateKey_ASN1(SSL *ssl, const uint8_t *der, size_t der_len) {
  266. UniquePtr<RSA> rsa(RSA_private_key_from_bytes(der, der_len));
  267. if (!rsa) {
  268. OPENSSL_PUT_ERROR(SSL, ERR_R_ASN1_LIB);
  269. return 0;
  270. }
  271. return SSL_use_RSAPrivateKey(ssl, rsa.get());
  272. }
  273. int SSL_use_PrivateKey(SSL *ssl, EVP_PKEY *pkey) {
  274. if (pkey == NULL) {
  275. OPENSSL_PUT_ERROR(SSL, ERR_R_PASSED_NULL_PARAMETER);
  276. return 0;
  277. }
  278. return ssl_set_pkey(ssl->cert, pkey);
  279. }
  280. int SSL_use_PrivateKey_ASN1(int type, SSL *ssl, const uint8_t *der,
  281. size_t der_len) {
  282. if (der_len > LONG_MAX) {
  283. OPENSSL_PUT_ERROR(SSL, ERR_R_OVERFLOW);
  284. return 0;
  285. }
  286. const uint8_t *p = der;
  287. UniquePtr<EVP_PKEY> pkey(d2i_PrivateKey(type, NULL, &p, (long)der_len));
  288. if (!pkey || p != der + der_len) {
  289. OPENSSL_PUT_ERROR(SSL, ERR_R_ASN1_LIB);
  290. return 0;
  291. }
  292. return SSL_use_PrivateKey(ssl, pkey.get());
  293. }
  294. int SSL_CTX_use_RSAPrivateKey(SSL_CTX *ctx, RSA *rsa) {
  295. if (rsa == NULL) {
  296. OPENSSL_PUT_ERROR(SSL, ERR_R_PASSED_NULL_PARAMETER);
  297. return 0;
  298. }
  299. UniquePtr<EVP_PKEY> pkey(EVP_PKEY_new());
  300. if (!pkey ||
  301. !EVP_PKEY_set1_RSA(pkey.get(), rsa)) {
  302. OPENSSL_PUT_ERROR(SSL, ERR_R_EVP_LIB);
  303. return 0;
  304. }
  305. return ssl_set_pkey(ctx->cert, pkey.get());
  306. }
  307. int SSL_CTX_use_RSAPrivateKey_ASN1(SSL_CTX *ctx, const uint8_t *der,
  308. size_t der_len) {
  309. UniquePtr<RSA> rsa(RSA_private_key_from_bytes(der, der_len));
  310. if (!rsa) {
  311. OPENSSL_PUT_ERROR(SSL, ERR_R_ASN1_LIB);
  312. return 0;
  313. }
  314. return SSL_CTX_use_RSAPrivateKey(ctx, rsa.get());
  315. }
  316. int SSL_CTX_use_PrivateKey(SSL_CTX *ctx, EVP_PKEY *pkey) {
  317. if (pkey == NULL) {
  318. OPENSSL_PUT_ERROR(SSL, ERR_R_PASSED_NULL_PARAMETER);
  319. return 0;
  320. }
  321. return ssl_set_pkey(ctx->cert, pkey);
  322. }
  323. int SSL_CTX_use_PrivateKey_ASN1(int type, SSL_CTX *ctx, const uint8_t *der,
  324. size_t der_len) {
  325. if (der_len > LONG_MAX) {
  326. OPENSSL_PUT_ERROR(SSL, ERR_R_OVERFLOW);
  327. return 0;
  328. }
  329. const uint8_t *p = der;
  330. UniquePtr<EVP_PKEY> pkey(d2i_PrivateKey(type, NULL, &p, (long)der_len));
  331. if (!pkey || p != der + der_len) {
  332. OPENSSL_PUT_ERROR(SSL, ERR_R_ASN1_LIB);
  333. return 0;
  334. }
  335. return SSL_CTX_use_PrivateKey(ctx, pkey.get());
  336. }
  337. void SSL_set_private_key_method(SSL *ssl,
  338. const SSL_PRIVATE_KEY_METHOD *key_method) {
  339. ssl->cert->key_method = key_method;
  340. }
  341. void SSL_CTX_set_private_key_method(SSL_CTX *ctx,
  342. const SSL_PRIVATE_KEY_METHOD *key_method) {
  343. ctx->cert->key_method = key_method;
  344. }
  345. const char *SSL_get_signature_algorithm_name(uint16_t sigalg,
  346. int include_curve) {
  347. switch (sigalg) {
  348. case SSL_SIGN_RSA_PKCS1_MD5_SHA1:
  349. return "rsa_pkcs1_md5_sha1";
  350. case SSL_SIGN_RSA_PKCS1_SHA1:
  351. return "rsa_pkcs1_sha1";
  352. case SSL_SIGN_RSA_PKCS1_SHA256:
  353. return "rsa_pkcs1_sha256";
  354. case SSL_SIGN_RSA_PKCS1_SHA384:
  355. return "rsa_pkcs1_sha384";
  356. case SSL_SIGN_RSA_PKCS1_SHA512:
  357. return "rsa_pkcs1_sha512";
  358. case SSL_SIGN_ECDSA_SHA1:
  359. return "ecdsa_sha1";
  360. case SSL_SIGN_ECDSA_SECP256R1_SHA256:
  361. return include_curve ? "ecdsa_secp256r1_sha256" : "ecdsa_sha256";
  362. case SSL_SIGN_ECDSA_SECP384R1_SHA384:
  363. return include_curve ? "ecdsa_secp384r1_sha384" : "ecdsa_sha384";
  364. case SSL_SIGN_ECDSA_SECP521R1_SHA512:
  365. return include_curve ? "ecdsa_secp521r1_sha512" : "ecdsa_sha512";
  366. case SSL_SIGN_RSA_PSS_SHA256:
  367. return "rsa_pss_sha256";
  368. case SSL_SIGN_RSA_PSS_SHA384:
  369. return "rsa_pss_sha384";
  370. case SSL_SIGN_RSA_PSS_SHA512:
  371. return "rsa_pss_sha512";
  372. case SSL_SIGN_ED25519:
  373. return "ed25519";
  374. default:
  375. return NULL;
  376. }
  377. }
  378. int SSL_get_signature_algorithm_key_type(uint16_t sigalg) {
  379. const SSL_SIGNATURE_ALGORITHM *alg = get_signature_algorithm(sigalg);
  380. return alg != nullptr ? alg->pkey_type : EVP_PKEY_NONE;
  381. }
  382. const EVP_MD *SSL_get_signature_algorithm_digest(uint16_t sigalg) {
  383. const SSL_SIGNATURE_ALGORITHM *alg = get_signature_algorithm(sigalg);
  384. if (alg == nullptr || alg->digest_func == nullptr) {
  385. return nullptr;
  386. }
  387. return alg->digest_func();
  388. }
  389. int SSL_is_signature_algorithm_rsa_pss(uint16_t sigalg) {
  390. const SSL_SIGNATURE_ALGORITHM *alg = get_signature_algorithm(sigalg);
  391. return alg != nullptr && alg->is_rsa_pss;
  392. }
  393. static int set_algorithm_prefs(uint16_t **out_prefs, size_t *out_num_prefs,
  394. const uint16_t *prefs, size_t num_prefs) {
  395. OPENSSL_free(*out_prefs);
  396. *out_num_prefs = 0;
  397. *out_prefs = (uint16_t *)BUF_memdup(prefs, num_prefs * sizeof(prefs[0]));
  398. if (*out_prefs == NULL) {
  399. OPENSSL_PUT_ERROR(SSL, ERR_R_MALLOC_FAILURE);
  400. return 0;
  401. }
  402. *out_num_prefs = num_prefs;
  403. return 1;
  404. }
  405. int SSL_CTX_set_signing_algorithm_prefs(SSL_CTX *ctx, const uint16_t *prefs,
  406. size_t num_prefs) {
  407. return set_algorithm_prefs(&ctx->cert->sigalgs, &ctx->cert->num_sigalgs,
  408. prefs, num_prefs);
  409. }
  410. int SSL_set_signing_algorithm_prefs(SSL *ssl, const uint16_t *prefs,
  411. size_t num_prefs) {
  412. return set_algorithm_prefs(&ssl->cert->sigalgs, &ssl->cert->num_sigalgs,
  413. prefs, num_prefs);
  414. }
  415. int SSL_CTX_set_verify_algorithm_prefs(SSL_CTX *ctx, const uint16_t *prefs,
  416. size_t num_prefs) {
  417. return set_algorithm_prefs(&ctx->verify_sigalgs, &ctx->num_verify_sigalgs,
  418. prefs, num_prefs);
  419. }