s3_lib.c 56 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525
  1. /* ssl/s3_lib.c */
  2. /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
  3. * All rights reserved.
  4. *
  5. * This package is an SSL implementation written
  6. * by Eric Young (eay@cryptsoft.com).
  7. * The implementation was written so as to conform with Netscapes SSL.
  8. *
  9. * This library is free for commercial and non-commercial use as long as
  10. * the following conditions are aheared to. The following conditions
  11. * apply to all code found in this distribution, be it the RC4, RSA,
  12. * lhash, DES, etc., code; not just the SSL code. The SSL documentation
  13. * included with this distribution is covered by the same copyright terms
  14. * except that the holder is Tim Hudson (tjh@cryptsoft.com).
  15. *
  16. * Copyright remains Eric Young's, and as such any Copyright notices in
  17. * the code are not to be removed.
  18. * If this package is used in a product, Eric Young should be given attribution
  19. * as the author of the parts of the library used.
  20. * This can be in the form of a textual message at program startup or
  21. * in documentation (online or textual) provided with the package.
  22. *
  23. * Redistribution and use in source and binary forms, with or without
  24. * modification, are permitted provided that the following conditions
  25. * are met:
  26. * 1. Redistributions of source code must retain the copyright
  27. * notice, this list of conditions and the following disclaimer.
  28. * 2. Redistributions in binary form must reproduce the above copyright
  29. * notice, this list of conditions and the following disclaimer in the
  30. * documentation and/or other materials provided with the distribution.
  31. * 3. All advertising materials mentioning features or use of this software
  32. * must display the following acknowledgement:
  33. * "This product includes cryptographic software written by
  34. * Eric Young (eay@cryptsoft.com)"
  35. * The word 'cryptographic' can be left out if the rouines from the library
  36. * being used are not cryptographic related :-).
  37. * 4. If you include any Windows specific code (or a derivative thereof) from
  38. * the apps directory (application code) you must include an acknowledgement:
  39. * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)"
  40. *
  41. * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND
  42. * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  43. * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
  44. * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
  45. * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
  46. * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
  47. * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
  48. * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
  49. * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
  50. * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  51. * SUCH DAMAGE.
  52. *
  53. * The licence and distribution terms for any publically available version or
  54. * derivative of this code cannot be changed. i.e. this code cannot simply be
  55. * copied and put under another distribution licence
  56. * [including the GNU Public Licence.]
  57. */
  58. /* ====================================================================
  59. * Copyright (c) 1998-2006 The OpenSSL Project. All rights reserved.
  60. *
  61. * Redistribution and use in source and binary forms, with or without
  62. * modification, are permitted provided that the following conditions
  63. * are met:
  64. *
  65. * 1. Redistributions of source code must retain the above copyright
  66. * notice, this list of conditions and the following disclaimer.
  67. *
  68. * 2. Redistributions in binary form must reproduce the above copyright
  69. * notice, this list of conditions and the following disclaimer in
  70. * the documentation and/or other materials provided with the
  71. * distribution.
  72. *
  73. * 3. All advertising materials mentioning features or use of this
  74. * software must display the following acknowledgment:
  75. * "This product includes software developed by the OpenSSL Project
  76. * for use in the OpenSSL Toolkit. (http://www.openssl.org/)"
  77. *
  78. * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to
  79. * endorse or promote products derived from this software without
  80. * prior written permission. For written permission, please contact
  81. * openssl-core@openssl.org.
  82. *
  83. * 5. Products derived from this software may not be called "OpenSSL"
  84. * nor may "OpenSSL" appear in their names without prior written
  85. * permission of the OpenSSL Project.
  86. *
  87. * 6. Redistributions of any form whatsoever must retain the following
  88. * acknowledgment:
  89. * "This product includes software developed by the OpenSSL Project
  90. * for use in the OpenSSL Toolkit (http://www.openssl.org/)"
  91. *
  92. * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY
  93. * EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  94. * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
  95. * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR
  96. * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
  97. * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
  98. * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
  99. * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
  100. * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
  101. * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
  102. * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
  103. * OF THE POSSIBILITY OF SUCH DAMAGE.
  104. * ====================================================================
  105. *
  106. * This product includes cryptographic software written by Eric Young
  107. * (eay@cryptsoft.com). This product includes software written by Tim
  108. * Hudson (tjh@cryptsoft.com).
  109. *
  110. */
  111. /* ====================================================================
  112. * Copyright 2002 Sun Microsystems, Inc. ALL RIGHTS RESERVED.
  113. *
  114. * Portions of the attached software ("Contribution") are developed by
  115. * SUN MICROSYSTEMS, INC., and are contributed to the OpenSSL project.
  116. *
  117. * The Contribution is licensed pursuant to the OpenSSL open source
  118. * license provided above.
  119. *
  120. * ECC cipher suite support in OpenSSL originally written by
  121. * Vipul Gupta and Sumit Gupta of Sun Microsystems Laboratories.
  122. *
  123. */
  124. /* ====================================================================
  125. * Copyright 2005 Nokia. All rights reserved.
  126. *
  127. * The portions of the attached software ("Contribution") is developed by
  128. * Nokia Corporation and is licensed pursuant to the OpenSSL open source
  129. * license.
  130. *
  131. * The Contribution, originally written by Mika Kousa and Pasi Eronen of
  132. * Nokia Corporation, consists of the "PSK" (Pre-Shared Key) ciphersuites
  133. * support (see RFC 4279) to OpenSSL.
  134. *
  135. * No patent licenses or other rights except those expressly stated in
  136. * the OpenSSL open source license shall be deemed granted or received
  137. * expressly, by implication, estoppel, or otherwise.
  138. *
  139. * No assurances are provided by Nokia that the Contribution does not
  140. * infringe the patent or other intellectual property rights of any third
  141. * party or that the license provides you with all the necessary rights
  142. * to make use of the Contribution.
  143. *
  144. * THE SOFTWARE IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND. IN
  145. * ADDITION TO THE DISCLAIMERS INCLUDED IN THE LICENSE, NOKIA
  146. * SPECIFICALLY DISCLAIMS ANY LIABILITY FOR CLAIMS BROUGHT BY YOU OR ANY
  147. * OTHER ENTITY BASED ON INFRINGEMENT OF INTELLECTUAL PROPERTY RIGHTS OR
  148. * OTHERWISE.
  149. */
  150. #include <stdio.h>
  151. #include <openssl/objects.h>
  152. #include "ssl_locl.h"
  153. #include "kssl_lcl.h"
  154. #ifndef OPENSSL_NO_TLSEXT
  155. #ifndef OPENSSL_NO_EC
  156. #include "../crypto/ec/ec_lcl.h"
  157. #endif /* OPENSSL_NO_EC */
  158. #endif /* OPENSSL_NO_TLSEXT */
  159. #include <openssl/md5.h>
  160. #ifndef OPENSSL_NO_DH
  161. #include <openssl/dh.h>
  162. #endif
  163. const char *ssl3_version_str="SSLv3" OPENSSL_VERSION_PTEXT;
  164. #define SSL3_NUM_CIPHERS (sizeof(ssl3_ciphers)/sizeof(SSL_CIPHER))
  165. /* list of available SSLv3 ciphers (sorted by id) */
  166. OPENSSL_GLOBAL SSL_CIPHER ssl3_ciphers[]={
  167. /* The RSA ciphers */
  168. /* Cipher 01 */
  169. {
  170. 1,
  171. SSL3_TXT_RSA_NULL_MD5,
  172. SSL3_CK_RSA_NULL_MD5,
  173. SSL_kRSA|SSL_aRSA|SSL_eNULL |SSL_MD5|SSL_SSLV3,
  174. SSL_NOT_EXP|SSL_STRONG_NONE,
  175. 0,
  176. 0,
  177. 0,
  178. SSL_ALL_CIPHERS,
  179. SSL_ALL_STRENGTHS,
  180. },
  181. /* Cipher 02 */
  182. {
  183. 1,
  184. SSL3_TXT_RSA_NULL_SHA,
  185. SSL3_CK_RSA_NULL_SHA,
  186. SSL_kRSA|SSL_aRSA|SSL_eNULL |SSL_SHA1|SSL_SSLV3,
  187. SSL_NOT_EXP|SSL_STRONG_NONE,
  188. 0,
  189. 0,
  190. 0,
  191. SSL_ALL_CIPHERS,
  192. SSL_ALL_STRENGTHS,
  193. },
  194. /* Cipher 03 */
  195. {
  196. 1,
  197. SSL3_TXT_RSA_RC4_40_MD5,
  198. SSL3_CK_RSA_RC4_40_MD5,
  199. SSL_kRSA|SSL_aRSA|SSL_RC4 |SSL_MD5 |SSL_SSLV3,
  200. SSL_EXPORT|SSL_EXP40,
  201. 0,
  202. 40,
  203. 128,
  204. SSL_ALL_CIPHERS,
  205. SSL_ALL_STRENGTHS,
  206. },
  207. /* Cipher 04 */
  208. {
  209. 1,
  210. SSL3_TXT_RSA_RC4_128_MD5,
  211. SSL3_CK_RSA_RC4_128_MD5,
  212. SSL_kRSA|SSL_aRSA|SSL_RC4 |SSL_MD5|SSL_SSLV3,
  213. SSL_NOT_EXP|SSL_MEDIUM,
  214. 0,
  215. 128,
  216. 128,
  217. SSL_ALL_CIPHERS,
  218. SSL_ALL_STRENGTHS,
  219. },
  220. /* Cipher 05 */
  221. {
  222. 1,
  223. SSL3_TXT_RSA_RC4_128_SHA,
  224. SSL3_CK_RSA_RC4_128_SHA,
  225. SSL_kRSA|SSL_aRSA|SSL_RC4 |SSL_SHA1|SSL_SSLV3,
  226. SSL_NOT_EXP|SSL_MEDIUM,
  227. 0,
  228. 128,
  229. 128,
  230. SSL_ALL_CIPHERS,
  231. SSL_ALL_STRENGTHS,
  232. },
  233. /* Cipher 06 */
  234. {
  235. 1,
  236. SSL3_TXT_RSA_RC2_40_MD5,
  237. SSL3_CK_RSA_RC2_40_MD5,
  238. SSL_kRSA|SSL_aRSA|SSL_RC2 |SSL_MD5 |SSL_SSLV3,
  239. SSL_EXPORT|SSL_EXP40,
  240. 0,
  241. 40,
  242. 128,
  243. SSL_ALL_CIPHERS,
  244. SSL_ALL_STRENGTHS,
  245. },
  246. /* Cipher 07 */
  247. #ifndef OPENSSL_NO_IDEA
  248. {
  249. 1,
  250. SSL3_TXT_RSA_IDEA_128_SHA,
  251. SSL3_CK_RSA_IDEA_128_SHA,
  252. SSL_kRSA|SSL_aRSA|SSL_IDEA |SSL_SHA1|SSL_SSLV3,
  253. SSL_NOT_EXP|SSL_MEDIUM,
  254. 0,
  255. 128,
  256. 128,
  257. SSL_ALL_CIPHERS,
  258. SSL_ALL_STRENGTHS,
  259. },
  260. #endif
  261. /* Cipher 08 */
  262. {
  263. 1,
  264. SSL3_TXT_RSA_DES_40_CBC_SHA,
  265. SSL3_CK_RSA_DES_40_CBC_SHA,
  266. SSL_kRSA|SSL_aRSA|SSL_DES|SSL_SHA1|SSL_SSLV3,
  267. SSL_EXPORT|SSL_EXP40,
  268. 0,
  269. 40,
  270. 56,
  271. SSL_ALL_CIPHERS,
  272. SSL_ALL_STRENGTHS,
  273. },
  274. /* Cipher 09 */
  275. {
  276. 1,
  277. SSL3_TXT_RSA_DES_64_CBC_SHA,
  278. SSL3_CK_RSA_DES_64_CBC_SHA,
  279. SSL_kRSA|SSL_aRSA|SSL_DES |SSL_SHA1|SSL_SSLV3,
  280. SSL_NOT_EXP|SSL_LOW,
  281. 0,
  282. 56,
  283. 56,
  284. SSL_ALL_CIPHERS,
  285. SSL_ALL_STRENGTHS,
  286. },
  287. /* Cipher 0A */
  288. {
  289. 1,
  290. SSL3_TXT_RSA_DES_192_CBC3_SHA,
  291. SSL3_CK_RSA_DES_192_CBC3_SHA,
  292. SSL_kRSA|SSL_aRSA|SSL_3DES |SSL_SHA1|SSL_SSLV3,
  293. SSL_NOT_EXP|SSL_HIGH,
  294. 0,
  295. 168,
  296. 168,
  297. SSL_ALL_CIPHERS,
  298. SSL_ALL_STRENGTHS,
  299. },
  300. /* The DH ciphers */
  301. /* Cipher 0B */
  302. {
  303. 0,
  304. SSL3_TXT_DH_DSS_DES_40_CBC_SHA,
  305. SSL3_CK_DH_DSS_DES_40_CBC_SHA,
  306. SSL_kDHd |SSL_aDH|SSL_DES|SSL_SHA1|SSL_SSLV3,
  307. SSL_EXPORT|SSL_EXP40,
  308. 0,
  309. 40,
  310. 56,
  311. SSL_ALL_CIPHERS,
  312. SSL_ALL_STRENGTHS,
  313. },
  314. /* Cipher 0C */
  315. {
  316. 0,
  317. SSL3_TXT_DH_DSS_DES_64_CBC_SHA,
  318. SSL3_CK_DH_DSS_DES_64_CBC_SHA,
  319. SSL_kDHd |SSL_aDH|SSL_DES |SSL_SHA1|SSL_SSLV3,
  320. SSL_NOT_EXP|SSL_LOW,
  321. 0,
  322. 56,
  323. 56,
  324. SSL_ALL_CIPHERS,
  325. SSL_ALL_STRENGTHS,
  326. },
  327. /* Cipher 0D */
  328. {
  329. 0,
  330. SSL3_TXT_DH_DSS_DES_192_CBC3_SHA,
  331. SSL3_CK_DH_DSS_DES_192_CBC3_SHA,
  332. SSL_kDHd |SSL_aDH|SSL_3DES |SSL_SHA1|SSL_SSLV3,
  333. SSL_NOT_EXP|SSL_HIGH,
  334. 0,
  335. 168,
  336. 168,
  337. SSL_ALL_CIPHERS,
  338. SSL_ALL_STRENGTHS,
  339. },
  340. /* Cipher 0E */
  341. {
  342. 0,
  343. SSL3_TXT_DH_RSA_DES_40_CBC_SHA,
  344. SSL3_CK_DH_RSA_DES_40_CBC_SHA,
  345. SSL_kDHr |SSL_aDH|SSL_DES|SSL_SHA1|SSL_SSLV3,
  346. SSL_EXPORT|SSL_EXP40,
  347. 0,
  348. 40,
  349. 56,
  350. SSL_ALL_CIPHERS,
  351. SSL_ALL_STRENGTHS,
  352. },
  353. /* Cipher 0F */
  354. {
  355. 0,
  356. SSL3_TXT_DH_RSA_DES_64_CBC_SHA,
  357. SSL3_CK_DH_RSA_DES_64_CBC_SHA,
  358. SSL_kDHr |SSL_aDH|SSL_DES |SSL_SHA1|SSL_SSLV3,
  359. SSL_NOT_EXP|SSL_LOW,
  360. 0,
  361. 56,
  362. 56,
  363. SSL_ALL_CIPHERS,
  364. SSL_ALL_STRENGTHS,
  365. },
  366. /* Cipher 10 */
  367. {
  368. 0,
  369. SSL3_TXT_DH_RSA_DES_192_CBC3_SHA,
  370. SSL3_CK_DH_RSA_DES_192_CBC3_SHA,
  371. SSL_kDHr |SSL_aDH|SSL_3DES |SSL_SHA1|SSL_SSLV3,
  372. SSL_NOT_EXP|SSL_HIGH,
  373. 0,
  374. 168,
  375. 168,
  376. SSL_ALL_CIPHERS,
  377. SSL_ALL_STRENGTHS,
  378. },
  379. /* The Ephemeral DH ciphers */
  380. /* Cipher 11 */
  381. {
  382. 1,
  383. SSL3_TXT_EDH_DSS_DES_40_CBC_SHA,
  384. SSL3_CK_EDH_DSS_DES_40_CBC_SHA,
  385. SSL_kEDH|SSL_aDSS|SSL_DES|SSL_SHA1|SSL_SSLV3,
  386. SSL_EXPORT|SSL_EXP40,
  387. 0,
  388. 40,
  389. 56,
  390. SSL_ALL_CIPHERS,
  391. SSL_ALL_STRENGTHS,
  392. },
  393. /* Cipher 12 */
  394. {
  395. 1,
  396. SSL3_TXT_EDH_DSS_DES_64_CBC_SHA,
  397. SSL3_CK_EDH_DSS_DES_64_CBC_SHA,
  398. SSL_kEDH|SSL_aDSS|SSL_DES |SSL_SHA1|SSL_SSLV3,
  399. SSL_NOT_EXP|SSL_LOW,
  400. 0,
  401. 56,
  402. 56,
  403. SSL_ALL_CIPHERS,
  404. SSL_ALL_STRENGTHS,
  405. },
  406. /* Cipher 13 */
  407. {
  408. 1,
  409. SSL3_TXT_EDH_DSS_DES_192_CBC3_SHA,
  410. SSL3_CK_EDH_DSS_DES_192_CBC3_SHA,
  411. SSL_kEDH|SSL_aDSS|SSL_3DES |SSL_SHA1|SSL_SSLV3,
  412. SSL_NOT_EXP|SSL_HIGH,
  413. 0,
  414. 168,
  415. 168,
  416. SSL_ALL_CIPHERS,
  417. SSL_ALL_STRENGTHS,
  418. },
  419. /* Cipher 14 */
  420. {
  421. 1,
  422. SSL3_TXT_EDH_RSA_DES_40_CBC_SHA,
  423. SSL3_CK_EDH_RSA_DES_40_CBC_SHA,
  424. SSL_kEDH|SSL_aRSA|SSL_DES|SSL_SHA1|SSL_SSLV3,
  425. SSL_EXPORT|SSL_EXP40,
  426. 0,
  427. 40,
  428. 56,
  429. SSL_ALL_CIPHERS,
  430. SSL_ALL_STRENGTHS,
  431. },
  432. /* Cipher 15 */
  433. {
  434. 1,
  435. SSL3_TXT_EDH_RSA_DES_64_CBC_SHA,
  436. SSL3_CK_EDH_RSA_DES_64_CBC_SHA,
  437. SSL_kEDH|SSL_aRSA|SSL_DES |SSL_SHA1|SSL_SSLV3,
  438. SSL_NOT_EXP|SSL_LOW,
  439. 0,
  440. 56,
  441. 56,
  442. SSL_ALL_CIPHERS,
  443. SSL_ALL_STRENGTHS,
  444. },
  445. /* Cipher 16 */
  446. {
  447. 1,
  448. SSL3_TXT_EDH_RSA_DES_192_CBC3_SHA,
  449. SSL3_CK_EDH_RSA_DES_192_CBC3_SHA,
  450. SSL_kEDH|SSL_aRSA|SSL_3DES |SSL_SHA1|SSL_SSLV3,
  451. SSL_NOT_EXP|SSL_HIGH,
  452. 0,
  453. 168,
  454. 168,
  455. SSL_ALL_CIPHERS,
  456. SSL_ALL_STRENGTHS,
  457. },
  458. /* Cipher 17 */
  459. {
  460. 1,
  461. SSL3_TXT_ADH_RC4_40_MD5,
  462. SSL3_CK_ADH_RC4_40_MD5,
  463. SSL_kEDH |SSL_aNULL|SSL_RC4 |SSL_MD5 |SSL_SSLV3,
  464. SSL_EXPORT|SSL_EXP40,
  465. 0,
  466. 40,
  467. 128,
  468. SSL_ALL_CIPHERS,
  469. SSL_ALL_STRENGTHS,
  470. },
  471. /* Cipher 18 */
  472. {
  473. 1,
  474. SSL3_TXT_ADH_RC4_128_MD5,
  475. SSL3_CK_ADH_RC4_128_MD5,
  476. SSL_kEDH |SSL_aNULL|SSL_RC4 |SSL_MD5 |SSL_SSLV3,
  477. SSL_NOT_EXP|SSL_MEDIUM,
  478. 0,
  479. 128,
  480. 128,
  481. SSL_ALL_CIPHERS,
  482. SSL_ALL_STRENGTHS,
  483. },
  484. /* Cipher 19 */
  485. {
  486. 1,
  487. SSL3_TXT_ADH_DES_40_CBC_SHA,
  488. SSL3_CK_ADH_DES_40_CBC_SHA,
  489. SSL_kEDH |SSL_aNULL|SSL_DES|SSL_SHA1|SSL_SSLV3,
  490. SSL_EXPORT|SSL_EXP40,
  491. 0,
  492. 40,
  493. 128,
  494. SSL_ALL_CIPHERS,
  495. SSL_ALL_STRENGTHS,
  496. },
  497. /* Cipher 1A */
  498. {
  499. 1,
  500. SSL3_TXT_ADH_DES_64_CBC_SHA,
  501. SSL3_CK_ADH_DES_64_CBC_SHA,
  502. SSL_kEDH |SSL_aNULL|SSL_DES |SSL_SHA1|SSL_SSLV3,
  503. SSL_NOT_EXP|SSL_LOW,
  504. 0,
  505. 56,
  506. 56,
  507. SSL_ALL_CIPHERS,
  508. SSL_ALL_STRENGTHS,
  509. },
  510. /* Cipher 1B */
  511. {
  512. 1,
  513. SSL3_TXT_ADH_DES_192_CBC_SHA,
  514. SSL3_CK_ADH_DES_192_CBC_SHA,
  515. SSL_kEDH |SSL_aNULL|SSL_3DES |SSL_SHA1|SSL_SSLV3,
  516. SSL_NOT_EXP|SSL_HIGH,
  517. 0,
  518. 168,
  519. 168,
  520. SSL_ALL_CIPHERS,
  521. SSL_ALL_STRENGTHS,
  522. },
  523. /* Fortezza */
  524. /* Cipher 1C */
  525. {
  526. 0,
  527. SSL3_TXT_FZA_DMS_NULL_SHA,
  528. SSL3_CK_FZA_DMS_NULL_SHA,
  529. SSL_kFZA|SSL_aFZA |SSL_eNULL |SSL_SHA1|SSL_SSLV3,
  530. SSL_NOT_EXP|SSL_STRONG_NONE,
  531. 0,
  532. 0,
  533. 0,
  534. SSL_ALL_CIPHERS,
  535. SSL_ALL_STRENGTHS,
  536. },
  537. /* Cipher 1D */
  538. {
  539. 0,
  540. SSL3_TXT_FZA_DMS_FZA_SHA,
  541. SSL3_CK_FZA_DMS_FZA_SHA,
  542. SSL_kFZA|SSL_aFZA |SSL_eFZA |SSL_SHA1|SSL_SSLV3,
  543. SSL_NOT_EXP|SSL_STRONG_NONE,
  544. 0,
  545. 0,
  546. 0,
  547. SSL_ALL_CIPHERS,
  548. SSL_ALL_STRENGTHS,
  549. },
  550. #if 0
  551. /* Cipher 1E */
  552. {
  553. 0,
  554. SSL3_TXT_FZA_DMS_RC4_SHA,
  555. SSL3_CK_FZA_DMS_RC4_SHA,
  556. SSL_kFZA|SSL_aFZA |SSL_RC4 |SSL_SHA1|SSL_SSLV3,
  557. SSL_NOT_EXP|SSL_MEDIUM,
  558. 0,
  559. 128,
  560. 128,
  561. SSL_ALL_CIPHERS,
  562. SSL_ALL_STRENGTHS,
  563. },
  564. #endif
  565. #ifndef OPENSSL_NO_KRB5
  566. /* The Kerberos ciphers
  567. ** 20000107 VRS: And the first shall be last,
  568. ** in hopes of avoiding the lynx ssl renegotiation problem.
  569. */
  570. /* Cipher 1E VRS */
  571. {
  572. 1,
  573. SSL3_TXT_KRB5_DES_64_CBC_SHA,
  574. SSL3_CK_KRB5_DES_64_CBC_SHA,
  575. SSL_kKRB5|SSL_aKRB5| SSL_DES|SSL_SHA1 |SSL_SSLV3,
  576. SSL_NOT_EXP|SSL_LOW,
  577. 0,
  578. 56,
  579. 56,
  580. SSL_ALL_CIPHERS,
  581. SSL_ALL_STRENGTHS,
  582. },
  583. /* Cipher 1F VRS */
  584. {
  585. 1,
  586. SSL3_TXT_KRB5_DES_192_CBC3_SHA,
  587. SSL3_CK_KRB5_DES_192_CBC3_SHA,
  588. SSL_kKRB5|SSL_aKRB5| SSL_3DES|SSL_SHA1 |SSL_SSLV3,
  589. SSL_NOT_EXP|SSL_HIGH,
  590. 0,
  591. 112,
  592. 168,
  593. SSL_ALL_CIPHERS,
  594. SSL_ALL_STRENGTHS,
  595. },
  596. /* Cipher 20 VRS */
  597. {
  598. 1,
  599. SSL3_TXT_KRB5_RC4_128_SHA,
  600. SSL3_CK_KRB5_RC4_128_SHA,
  601. SSL_kKRB5|SSL_aKRB5| SSL_RC4|SSL_SHA1 |SSL_SSLV3,
  602. SSL_NOT_EXP|SSL_MEDIUM,
  603. 0,
  604. 128,
  605. 128,
  606. SSL_ALL_CIPHERS,
  607. SSL_ALL_STRENGTHS,
  608. },
  609. /* Cipher 21 VRS */
  610. {
  611. 1,
  612. SSL3_TXT_KRB5_IDEA_128_CBC_SHA,
  613. SSL3_CK_KRB5_IDEA_128_CBC_SHA,
  614. SSL_kKRB5|SSL_aKRB5| SSL_IDEA|SSL_SHA1 |SSL_SSLV3,
  615. SSL_NOT_EXP|SSL_MEDIUM,
  616. 0,
  617. 128,
  618. 128,
  619. SSL_ALL_CIPHERS,
  620. SSL_ALL_STRENGTHS,
  621. },
  622. /* Cipher 22 VRS */
  623. {
  624. 1,
  625. SSL3_TXT_KRB5_DES_64_CBC_MD5,
  626. SSL3_CK_KRB5_DES_64_CBC_MD5,
  627. SSL_kKRB5|SSL_aKRB5| SSL_DES|SSL_MD5 |SSL_SSLV3,
  628. SSL_NOT_EXP|SSL_LOW,
  629. 0,
  630. 56,
  631. 56,
  632. SSL_ALL_CIPHERS,
  633. SSL_ALL_STRENGTHS,
  634. },
  635. /* Cipher 23 VRS */
  636. {
  637. 1,
  638. SSL3_TXT_KRB5_DES_192_CBC3_MD5,
  639. SSL3_CK_KRB5_DES_192_CBC3_MD5,
  640. SSL_kKRB5|SSL_aKRB5| SSL_3DES|SSL_MD5 |SSL_SSLV3,
  641. SSL_NOT_EXP|SSL_HIGH,
  642. 0,
  643. 112,
  644. 168,
  645. SSL_ALL_CIPHERS,
  646. SSL_ALL_STRENGTHS,
  647. },
  648. /* Cipher 24 VRS */
  649. {
  650. 1,
  651. SSL3_TXT_KRB5_RC4_128_MD5,
  652. SSL3_CK_KRB5_RC4_128_MD5,
  653. SSL_kKRB5|SSL_aKRB5| SSL_RC4|SSL_MD5 |SSL_SSLV3,
  654. SSL_NOT_EXP|SSL_MEDIUM,
  655. 0,
  656. 128,
  657. 128,
  658. SSL_ALL_CIPHERS,
  659. SSL_ALL_STRENGTHS,
  660. },
  661. /* Cipher 25 VRS */
  662. {
  663. 1,
  664. SSL3_TXT_KRB5_IDEA_128_CBC_MD5,
  665. SSL3_CK_KRB5_IDEA_128_CBC_MD5,
  666. SSL_kKRB5|SSL_aKRB5| SSL_IDEA|SSL_MD5 |SSL_SSLV3,
  667. SSL_NOT_EXP|SSL_MEDIUM,
  668. 0,
  669. 128,
  670. 128,
  671. SSL_ALL_CIPHERS,
  672. SSL_ALL_STRENGTHS,
  673. },
  674. /* Cipher 26 VRS */
  675. {
  676. 1,
  677. SSL3_TXT_KRB5_DES_40_CBC_SHA,
  678. SSL3_CK_KRB5_DES_40_CBC_SHA,
  679. SSL_kKRB5|SSL_aKRB5| SSL_DES|SSL_SHA1 |SSL_SSLV3,
  680. SSL_EXPORT|SSL_EXP40,
  681. 0,
  682. 40,
  683. 56,
  684. SSL_ALL_CIPHERS,
  685. SSL_ALL_STRENGTHS,
  686. },
  687. /* Cipher 27 VRS */
  688. {
  689. 1,
  690. SSL3_TXT_KRB5_RC2_40_CBC_SHA,
  691. SSL3_CK_KRB5_RC2_40_CBC_SHA,
  692. SSL_kKRB5|SSL_aKRB5| SSL_RC2|SSL_SHA1 |SSL_SSLV3,
  693. SSL_EXPORT|SSL_EXP40,
  694. 0,
  695. 40,
  696. 128,
  697. SSL_ALL_CIPHERS,
  698. SSL_ALL_STRENGTHS,
  699. },
  700. /* Cipher 28 VRS */
  701. {
  702. 1,
  703. SSL3_TXT_KRB5_RC4_40_SHA,
  704. SSL3_CK_KRB5_RC4_40_SHA,
  705. SSL_kKRB5|SSL_aKRB5| SSL_RC4|SSL_SHA1 |SSL_SSLV3,
  706. SSL_EXPORT|SSL_EXP40,
  707. 0,
  708. 128,
  709. 128,
  710. SSL_ALL_CIPHERS,
  711. SSL_ALL_STRENGTHS,
  712. },
  713. /* Cipher 29 VRS */
  714. {
  715. 1,
  716. SSL3_TXT_KRB5_DES_40_CBC_MD5,
  717. SSL3_CK_KRB5_DES_40_CBC_MD5,
  718. SSL_kKRB5|SSL_aKRB5| SSL_DES|SSL_MD5 |SSL_SSLV3,
  719. SSL_EXPORT|SSL_EXP40,
  720. 0,
  721. 40,
  722. 56,
  723. SSL_ALL_CIPHERS,
  724. SSL_ALL_STRENGTHS,
  725. },
  726. /* Cipher 2A VRS */
  727. {
  728. 1,
  729. SSL3_TXT_KRB5_RC2_40_CBC_MD5,
  730. SSL3_CK_KRB5_RC2_40_CBC_MD5,
  731. SSL_kKRB5|SSL_aKRB5| SSL_RC2|SSL_MD5 |SSL_SSLV3,
  732. SSL_EXPORT|SSL_EXP40,
  733. 0,
  734. 40,
  735. 128,
  736. SSL_ALL_CIPHERS,
  737. SSL_ALL_STRENGTHS,
  738. },
  739. /* Cipher 2B VRS */
  740. {
  741. 1,
  742. SSL3_TXT_KRB5_RC4_40_MD5,
  743. SSL3_CK_KRB5_RC4_40_MD5,
  744. SSL_kKRB5|SSL_aKRB5| SSL_RC4|SSL_MD5 |SSL_SSLV3,
  745. SSL_EXPORT|SSL_EXP40,
  746. 0,
  747. 128,
  748. 128,
  749. SSL_ALL_CIPHERS,
  750. SSL_ALL_STRENGTHS,
  751. },
  752. #endif /* OPENSSL_NO_KRB5 */
  753. /* New AES ciphersuites */
  754. /* Cipher 2F */
  755. {
  756. 1,
  757. TLS1_TXT_RSA_WITH_AES_128_SHA,
  758. TLS1_CK_RSA_WITH_AES_128_SHA,
  759. SSL_kRSA|SSL_aRSA|SSL_AES|SSL_SHA |SSL_TLSV1,
  760. SSL_NOT_EXP|SSL_HIGH,
  761. 0,
  762. 128,
  763. 128,
  764. SSL_ALL_CIPHERS,
  765. SSL_ALL_STRENGTHS,
  766. },
  767. /* Cipher 30 */
  768. {
  769. 0,
  770. TLS1_TXT_DH_DSS_WITH_AES_128_SHA,
  771. TLS1_CK_DH_DSS_WITH_AES_128_SHA,
  772. SSL_kDHd|SSL_aDH|SSL_AES|SSL_SHA|SSL_TLSV1,
  773. SSL_NOT_EXP|SSL_HIGH,
  774. 0,
  775. 128,
  776. 128,
  777. SSL_ALL_CIPHERS,
  778. SSL_ALL_STRENGTHS,
  779. },
  780. /* Cipher 31 */
  781. {
  782. 0,
  783. TLS1_TXT_DH_RSA_WITH_AES_128_SHA,
  784. TLS1_CK_DH_RSA_WITH_AES_128_SHA,
  785. SSL_kDHr|SSL_aDH|SSL_AES|SSL_SHA|SSL_TLSV1,
  786. SSL_NOT_EXP|SSL_HIGH,
  787. 0,
  788. 128,
  789. 128,
  790. SSL_ALL_CIPHERS,
  791. SSL_ALL_STRENGTHS,
  792. },
  793. /* Cipher 32 */
  794. {
  795. 1,
  796. TLS1_TXT_DHE_DSS_WITH_AES_128_SHA,
  797. TLS1_CK_DHE_DSS_WITH_AES_128_SHA,
  798. SSL_kEDH|SSL_aDSS|SSL_AES|SSL_SHA|SSL_TLSV1,
  799. SSL_NOT_EXP|SSL_HIGH,
  800. 0,
  801. 128,
  802. 128,
  803. SSL_ALL_CIPHERS,
  804. SSL_ALL_STRENGTHS,
  805. },
  806. /* Cipher 33 */
  807. {
  808. 1,
  809. TLS1_TXT_DHE_RSA_WITH_AES_128_SHA,
  810. TLS1_CK_DHE_RSA_WITH_AES_128_SHA,
  811. SSL_kEDH|SSL_aRSA|SSL_AES|SSL_SHA|SSL_TLSV1,
  812. SSL_NOT_EXP|SSL_HIGH,
  813. 0,
  814. 128,
  815. 128,
  816. SSL_ALL_CIPHERS,
  817. SSL_ALL_STRENGTHS,
  818. },
  819. /* Cipher 34 */
  820. {
  821. 1,
  822. TLS1_TXT_ADH_WITH_AES_128_SHA,
  823. TLS1_CK_ADH_WITH_AES_128_SHA,
  824. SSL_kEDH|SSL_aNULL|SSL_AES|SSL_SHA|SSL_TLSV1,
  825. SSL_NOT_EXP|SSL_HIGH,
  826. 0,
  827. 128,
  828. 128,
  829. SSL_ALL_CIPHERS,
  830. SSL_ALL_STRENGTHS,
  831. },
  832. /* Cipher 35 */
  833. {
  834. 1,
  835. TLS1_TXT_RSA_WITH_AES_256_SHA,
  836. TLS1_CK_RSA_WITH_AES_256_SHA,
  837. SSL_kRSA|SSL_aRSA|SSL_AES|SSL_SHA |SSL_TLSV1,
  838. SSL_NOT_EXP|SSL_HIGH,
  839. 0,
  840. 256,
  841. 256,
  842. SSL_ALL_CIPHERS,
  843. SSL_ALL_STRENGTHS,
  844. },
  845. /* Cipher 36 */
  846. {
  847. 0,
  848. TLS1_TXT_DH_DSS_WITH_AES_256_SHA,
  849. TLS1_CK_DH_DSS_WITH_AES_256_SHA,
  850. SSL_kDHd|SSL_aDH|SSL_AES|SSL_SHA|SSL_TLSV1,
  851. SSL_NOT_EXP|SSL_HIGH,
  852. 0,
  853. 256,
  854. 256,
  855. SSL_ALL_CIPHERS,
  856. SSL_ALL_STRENGTHS,
  857. },
  858. /* Cipher 37 */
  859. {
  860. 0,
  861. TLS1_TXT_DH_RSA_WITH_AES_256_SHA,
  862. TLS1_CK_DH_RSA_WITH_AES_256_SHA,
  863. SSL_kDHr|SSL_aDH|SSL_AES|SSL_SHA|SSL_TLSV1,
  864. SSL_NOT_EXP|SSL_HIGH,
  865. 0,
  866. 256,
  867. 256,
  868. SSL_ALL_CIPHERS,
  869. SSL_ALL_STRENGTHS,
  870. },
  871. /* Cipher 38 */
  872. {
  873. 1,
  874. TLS1_TXT_DHE_DSS_WITH_AES_256_SHA,
  875. TLS1_CK_DHE_DSS_WITH_AES_256_SHA,
  876. SSL_kEDH|SSL_aDSS|SSL_AES|SSL_SHA|SSL_TLSV1,
  877. SSL_NOT_EXP|SSL_HIGH,
  878. 0,
  879. 256,
  880. 256,
  881. SSL_ALL_CIPHERS,
  882. SSL_ALL_STRENGTHS,
  883. },
  884. /* Cipher 39 */
  885. {
  886. 1,
  887. TLS1_TXT_DHE_RSA_WITH_AES_256_SHA,
  888. TLS1_CK_DHE_RSA_WITH_AES_256_SHA,
  889. SSL_kEDH|SSL_aRSA|SSL_AES|SSL_SHA|SSL_TLSV1,
  890. SSL_NOT_EXP|SSL_HIGH,
  891. 0,
  892. 256,
  893. 256,
  894. SSL_ALL_CIPHERS,
  895. SSL_ALL_STRENGTHS,
  896. },
  897. /* Cipher 3A */
  898. {
  899. 1,
  900. TLS1_TXT_ADH_WITH_AES_256_SHA,
  901. TLS1_CK_ADH_WITH_AES_256_SHA,
  902. SSL_kEDH|SSL_aNULL|SSL_AES|SSL_SHA|SSL_TLSV1,
  903. SSL_NOT_EXP|SSL_HIGH,
  904. 0,
  905. 256,
  906. 256,
  907. SSL_ALL_CIPHERS,
  908. SSL_ALL_STRENGTHS,
  909. },
  910. #if TLS1_ALLOW_EXPERIMENTAL_CIPHERSUITES
  911. /* New TLS Export CipherSuites from expired ID */
  912. #if 0
  913. /* Cipher 60 */
  914. {
  915. 1,
  916. TLS1_TXT_RSA_EXPORT1024_WITH_RC4_56_MD5,
  917. TLS1_CK_RSA_EXPORT1024_WITH_RC4_56_MD5,
  918. SSL_kRSA|SSL_aRSA|SSL_RC4|SSL_MD5|SSL_TLSV1,
  919. SSL_EXPORT|SSL_EXP56,
  920. 0,
  921. 56,
  922. 128,
  923. SSL_ALL_CIPHERS,
  924. SSL_ALL_STRENGTHS,
  925. },
  926. /* Cipher 61 */
  927. {
  928. 1,
  929. TLS1_TXT_RSA_EXPORT1024_WITH_RC2_CBC_56_MD5,
  930. TLS1_CK_RSA_EXPORT1024_WITH_RC2_CBC_56_MD5,
  931. SSL_kRSA|SSL_aRSA|SSL_RC2|SSL_MD5|SSL_TLSV1,
  932. SSL_EXPORT|SSL_EXP56,
  933. 0,
  934. 56,
  935. 128,
  936. SSL_ALL_CIPHERS,
  937. SSL_ALL_STRENGTHS,
  938. },
  939. #endif
  940. /* Cipher 62 */
  941. {
  942. 1,
  943. TLS1_TXT_RSA_EXPORT1024_WITH_DES_CBC_SHA,
  944. TLS1_CK_RSA_EXPORT1024_WITH_DES_CBC_SHA,
  945. SSL_kRSA|SSL_aRSA|SSL_DES|SSL_SHA|SSL_TLSV1,
  946. SSL_EXPORT|SSL_EXP56,
  947. 0,
  948. 56,
  949. 56,
  950. SSL_ALL_CIPHERS,
  951. SSL_ALL_STRENGTHS,
  952. },
  953. /* Cipher 63 */
  954. {
  955. 1,
  956. TLS1_TXT_DHE_DSS_EXPORT1024_WITH_DES_CBC_SHA,
  957. TLS1_CK_DHE_DSS_EXPORT1024_WITH_DES_CBC_SHA,
  958. SSL_kEDH|SSL_aDSS|SSL_DES|SSL_SHA|SSL_TLSV1,
  959. SSL_EXPORT|SSL_EXP56,
  960. 0,
  961. 56,
  962. 56,
  963. SSL_ALL_CIPHERS,
  964. SSL_ALL_STRENGTHS,
  965. },
  966. /* Cipher 64 */
  967. {
  968. 1,
  969. TLS1_TXT_RSA_EXPORT1024_WITH_RC4_56_SHA,
  970. TLS1_CK_RSA_EXPORT1024_WITH_RC4_56_SHA,
  971. SSL_kRSA|SSL_aRSA|SSL_RC4|SSL_SHA|SSL_TLSV1,
  972. SSL_EXPORT|SSL_EXP56,
  973. 0,
  974. 56,
  975. 128,
  976. SSL_ALL_CIPHERS,
  977. SSL_ALL_STRENGTHS,
  978. },
  979. /* Cipher 65 */
  980. {
  981. 1,
  982. TLS1_TXT_DHE_DSS_EXPORT1024_WITH_RC4_56_SHA,
  983. TLS1_CK_DHE_DSS_EXPORT1024_WITH_RC4_56_SHA,
  984. SSL_kEDH|SSL_aDSS|SSL_RC4|SSL_SHA|SSL_TLSV1,
  985. SSL_EXPORT|SSL_EXP56,
  986. 0,
  987. 56,
  988. 128,
  989. SSL_ALL_CIPHERS,
  990. SSL_ALL_STRENGTHS,
  991. },
  992. /* Cipher 66 */
  993. {
  994. 1,
  995. TLS1_TXT_DHE_DSS_WITH_RC4_128_SHA,
  996. TLS1_CK_DHE_DSS_WITH_RC4_128_SHA,
  997. SSL_kEDH|SSL_aDSS|SSL_RC4|SSL_SHA|SSL_TLSV1,
  998. SSL_NOT_EXP|SSL_MEDIUM,
  999. 0,
  1000. 128,
  1001. 128,
  1002. SSL_ALL_CIPHERS,
  1003. SSL_ALL_STRENGTHS
  1004. },
  1005. #endif
  1006. #ifndef OPENSSL_NO_PSK
  1007. /* Cipher 8A */
  1008. {
  1009. 1,
  1010. TLS1_TXT_PSK_WITH_RC4_128_SHA,
  1011. TLS1_CK_PSK_WITH_RC4_128_SHA,
  1012. SSL_kPSK|SSL_aPSK|SSL_RC4|SSL_SHA|SSL_TLSV1,
  1013. SSL_NOT_EXP|SSL_MEDIUM,
  1014. 0,
  1015. 128,
  1016. 128,
  1017. SSL_ALL_CIPHERS,
  1018. SSL_ALL_STRENGTHS,
  1019. },
  1020. /* Cipher 8B */
  1021. {
  1022. 1,
  1023. TLS1_TXT_PSK_WITH_3DES_EDE_CBC_SHA,
  1024. TLS1_CK_PSK_WITH_3DES_EDE_CBC_SHA,
  1025. SSL_kPSK|SSL_aPSK|SSL_3DES|SSL_SHA|SSL_TLSV1,
  1026. SSL_NOT_EXP|SSL_HIGH,
  1027. 0,
  1028. 168,
  1029. 168,
  1030. SSL_ALL_CIPHERS,
  1031. SSL_ALL_STRENGTHS,
  1032. },
  1033. /* Cipher 8C */
  1034. {
  1035. 1,
  1036. TLS1_TXT_PSK_WITH_AES_128_CBC_SHA,
  1037. TLS1_CK_PSK_WITH_AES_128_CBC_SHA,
  1038. SSL_kPSK|SSL_aPSK|SSL_AES|SSL_SHA|SSL_TLSV1,
  1039. SSL_NOT_EXP|SSL_MEDIUM,
  1040. 0,
  1041. 128,
  1042. 128,
  1043. SSL_ALL_CIPHERS,
  1044. SSL_ALL_STRENGTHS,
  1045. },
  1046. /* Cipher 8D */
  1047. {
  1048. 1,
  1049. TLS1_TXT_PSK_WITH_AES_256_CBC_SHA,
  1050. TLS1_CK_PSK_WITH_AES_256_CBC_SHA,
  1051. SSL_kPSK|SSL_aPSK|SSL_AES|SSL_SHA|SSL_TLSV1,
  1052. SSL_NOT_EXP|SSL_HIGH,
  1053. 0,
  1054. 256,
  1055. 256,
  1056. SSL_ALL_CIPHERS,
  1057. SSL_ALL_STRENGTHS,
  1058. },
  1059. #endif /* OPENSSL_NO_PSK */
  1060. #ifndef OPENSSL_NO_ECDH
  1061. /* Cipher C001 */
  1062. {
  1063. 1,
  1064. TLS1_TXT_ECDH_ECDSA_WITH_NULL_SHA,
  1065. TLS1_CK_ECDH_ECDSA_WITH_NULL_SHA,
  1066. SSL_kECDH|SSL_aECDSA|SSL_eNULL|SSL_SHA|SSL_TLSV1,
  1067. SSL_NOT_EXP,
  1068. 0,
  1069. 0,
  1070. 0,
  1071. SSL_ALL_CIPHERS,
  1072. SSL_ALL_STRENGTHS,
  1073. },
  1074. /* Cipher C002 */
  1075. {
  1076. 1,
  1077. TLS1_TXT_ECDH_ECDSA_WITH_RC4_128_SHA,
  1078. TLS1_CK_ECDH_ECDSA_WITH_RC4_128_SHA,
  1079. SSL_kECDH|SSL_aECDSA|SSL_RC4|SSL_SHA|SSL_TLSV1,
  1080. SSL_NOT_EXP,
  1081. 0,
  1082. 128,
  1083. 128,
  1084. SSL_ALL_CIPHERS,
  1085. SSL_ALL_STRENGTHS,
  1086. },
  1087. /* Cipher C003 */
  1088. {
  1089. 1,
  1090. TLS1_TXT_ECDH_ECDSA_WITH_DES_192_CBC3_SHA,
  1091. TLS1_CK_ECDH_ECDSA_WITH_DES_192_CBC3_SHA,
  1092. SSL_kECDH|SSL_aECDSA|SSL_3DES|SSL_SHA|SSL_TLSV1,
  1093. SSL_NOT_EXP|SSL_HIGH,
  1094. 0,
  1095. 168,
  1096. 168,
  1097. SSL_ALL_CIPHERS,
  1098. SSL_ALL_STRENGTHS,
  1099. },
  1100. /* Cipher C004 */
  1101. {
  1102. 1,
  1103. TLS1_TXT_ECDH_ECDSA_WITH_AES_128_CBC_SHA,
  1104. TLS1_CK_ECDH_ECDSA_WITH_AES_128_CBC_SHA,
  1105. SSL_kECDH|SSL_aECDSA|SSL_AES|SSL_SHA|SSL_TLSV1,
  1106. SSL_NOT_EXP|SSL_HIGH,
  1107. 0,
  1108. 128,
  1109. 128,
  1110. SSL_ALL_CIPHERS,
  1111. SSL_ALL_STRENGTHS,
  1112. },
  1113. /* Cipher C005 */
  1114. {
  1115. 1,
  1116. TLS1_TXT_ECDH_ECDSA_WITH_AES_256_CBC_SHA,
  1117. TLS1_CK_ECDH_ECDSA_WITH_AES_256_CBC_SHA,
  1118. SSL_kECDH|SSL_aECDSA|SSL_AES|SSL_SHA|SSL_TLSV1,
  1119. SSL_NOT_EXP|SSL_HIGH,
  1120. 0,
  1121. 256,
  1122. 256,
  1123. SSL_ALL_CIPHERS,
  1124. SSL_ALL_STRENGTHS,
  1125. },
  1126. /* Cipher C006 */
  1127. {
  1128. 1,
  1129. TLS1_TXT_ECDHE_ECDSA_WITH_NULL_SHA,
  1130. TLS1_CK_ECDHE_ECDSA_WITH_NULL_SHA,
  1131. SSL_kECDHE|SSL_aECDSA|SSL_eNULL|SSL_SHA|SSL_TLSV1,
  1132. SSL_NOT_EXP,
  1133. 0,
  1134. 0,
  1135. 0,
  1136. SSL_ALL_CIPHERS,
  1137. SSL_ALL_STRENGTHS,
  1138. },
  1139. /* Cipher C007 */
  1140. {
  1141. 1,
  1142. TLS1_TXT_ECDHE_ECDSA_WITH_RC4_128_SHA,
  1143. TLS1_CK_ECDHE_ECDSA_WITH_RC4_128_SHA,
  1144. SSL_kECDHE|SSL_aECDSA|SSL_RC4|SSL_SHA|SSL_TLSV1,
  1145. SSL_NOT_EXP,
  1146. 0,
  1147. 128,
  1148. 128,
  1149. SSL_ALL_CIPHERS,
  1150. SSL_ALL_STRENGTHS,
  1151. },
  1152. /* Cipher C008 */
  1153. {
  1154. 1,
  1155. TLS1_TXT_ECDHE_ECDSA_WITH_DES_192_CBC3_SHA,
  1156. TLS1_CK_ECDHE_ECDSA_WITH_DES_192_CBC3_SHA,
  1157. SSL_kECDHE|SSL_aECDSA|SSL_3DES|SSL_SHA|SSL_TLSV1,
  1158. SSL_NOT_EXP|SSL_HIGH,
  1159. 0,
  1160. 168,
  1161. 168,
  1162. SSL_ALL_CIPHERS,
  1163. SSL_ALL_STRENGTHS,
  1164. },
  1165. /* Cipher C009 */
  1166. {
  1167. 1,
  1168. TLS1_TXT_ECDHE_ECDSA_WITH_AES_128_CBC_SHA,
  1169. TLS1_CK_ECDHE_ECDSA_WITH_AES_128_CBC_SHA,
  1170. SSL_kECDHE|SSL_aECDSA|SSL_AES|SSL_SHA|SSL_TLSV1,
  1171. SSL_NOT_EXP|SSL_HIGH,
  1172. 0,
  1173. 128,
  1174. 128,
  1175. SSL_ALL_CIPHERS,
  1176. SSL_ALL_STRENGTHS,
  1177. },
  1178. /* Cipher C00A */
  1179. {
  1180. 1,
  1181. TLS1_TXT_ECDHE_ECDSA_WITH_AES_256_CBC_SHA,
  1182. TLS1_CK_ECDHE_ECDSA_WITH_AES_256_CBC_SHA,
  1183. SSL_kECDHE|SSL_aECDSA|SSL_AES|SSL_SHA|SSL_TLSV1,
  1184. SSL_NOT_EXP|SSL_HIGH,
  1185. 0,
  1186. 256,
  1187. 256,
  1188. SSL_ALL_CIPHERS,
  1189. SSL_ALL_STRENGTHS,
  1190. },
  1191. /* Cipher C00B */
  1192. {
  1193. 1,
  1194. TLS1_TXT_ECDH_RSA_WITH_NULL_SHA,
  1195. TLS1_CK_ECDH_RSA_WITH_NULL_SHA,
  1196. SSL_kECDH|SSL_aRSA|SSL_eNULL|SSL_SHA|SSL_TLSV1,
  1197. SSL_NOT_EXP,
  1198. 0,
  1199. 0,
  1200. 0,
  1201. SSL_ALL_CIPHERS,
  1202. SSL_ALL_STRENGTHS,
  1203. },
  1204. /* Cipher C00C */
  1205. {
  1206. 1,
  1207. TLS1_TXT_ECDH_RSA_WITH_RC4_128_SHA,
  1208. TLS1_CK_ECDH_RSA_WITH_RC4_128_SHA,
  1209. SSL_kECDH|SSL_aRSA|SSL_RC4|SSL_SHA|SSL_TLSV1,
  1210. SSL_NOT_EXP,
  1211. 0,
  1212. 128,
  1213. 128,
  1214. SSL_ALL_CIPHERS,
  1215. SSL_ALL_STRENGTHS,
  1216. },
  1217. /* Cipher C00D */
  1218. {
  1219. 1,
  1220. TLS1_TXT_ECDH_RSA_WITH_DES_192_CBC3_SHA,
  1221. TLS1_CK_ECDH_RSA_WITH_DES_192_CBC3_SHA,
  1222. SSL_kECDH|SSL_aRSA|SSL_3DES|SSL_SHA|SSL_TLSV1,
  1223. SSL_NOT_EXP|SSL_HIGH,
  1224. 0,
  1225. 168,
  1226. 168,
  1227. SSL_ALL_CIPHERS,
  1228. SSL_ALL_STRENGTHS,
  1229. },
  1230. /* Cipher C00E */
  1231. {
  1232. 1,
  1233. TLS1_TXT_ECDH_RSA_WITH_AES_128_CBC_SHA,
  1234. TLS1_CK_ECDH_RSA_WITH_AES_128_CBC_SHA,
  1235. SSL_kECDH|SSL_aRSA|SSL_AES|SSL_SHA|SSL_TLSV1,
  1236. SSL_NOT_EXP|SSL_HIGH,
  1237. 0,
  1238. 128,
  1239. 128,
  1240. SSL_ALL_CIPHERS,
  1241. SSL_ALL_STRENGTHS,
  1242. },
  1243. /* Cipher C00F */
  1244. {
  1245. 1,
  1246. TLS1_TXT_ECDH_RSA_WITH_AES_256_CBC_SHA,
  1247. TLS1_CK_ECDH_RSA_WITH_AES_256_CBC_SHA,
  1248. SSL_kECDH|SSL_aRSA|SSL_AES|SSL_SHA|SSL_TLSV1,
  1249. SSL_NOT_EXP|SSL_HIGH,
  1250. 0,
  1251. 256,
  1252. 256,
  1253. SSL_ALL_CIPHERS,
  1254. SSL_ALL_STRENGTHS,
  1255. },
  1256. /* Cipher C010 */
  1257. {
  1258. 1,
  1259. TLS1_TXT_ECDHE_RSA_WITH_NULL_SHA,
  1260. TLS1_CK_ECDHE_RSA_WITH_NULL_SHA,
  1261. SSL_kECDHE|SSL_aRSA|SSL_eNULL|SSL_SHA|SSL_TLSV1,
  1262. SSL_NOT_EXP,
  1263. 0,
  1264. 0,
  1265. 0,
  1266. SSL_ALL_CIPHERS,
  1267. SSL_ALL_STRENGTHS,
  1268. },
  1269. /* Cipher C011 */
  1270. {
  1271. 1,
  1272. TLS1_TXT_ECDHE_RSA_WITH_RC4_128_SHA,
  1273. TLS1_CK_ECDHE_RSA_WITH_RC4_128_SHA,
  1274. SSL_kECDHE|SSL_aRSA|SSL_RC4|SSL_SHA|SSL_TLSV1,
  1275. SSL_NOT_EXP,
  1276. 0,
  1277. 128,
  1278. 128,
  1279. SSL_ALL_CIPHERS,
  1280. SSL_ALL_STRENGTHS,
  1281. },
  1282. /* Cipher C012 */
  1283. {
  1284. 1,
  1285. TLS1_TXT_ECDHE_RSA_WITH_DES_192_CBC3_SHA,
  1286. TLS1_CK_ECDHE_RSA_WITH_DES_192_CBC3_SHA,
  1287. SSL_kECDHE|SSL_aRSA|SSL_3DES|SSL_SHA|SSL_TLSV1,
  1288. SSL_NOT_EXP|SSL_HIGH,
  1289. 0,
  1290. 168,
  1291. 168,
  1292. SSL_ALL_CIPHERS,
  1293. SSL_ALL_STRENGTHS,
  1294. },
  1295. /* Cipher C013 */
  1296. {
  1297. 1,
  1298. TLS1_TXT_ECDHE_RSA_WITH_AES_128_CBC_SHA,
  1299. TLS1_CK_ECDHE_RSA_WITH_AES_128_CBC_SHA,
  1300. SSL_kECDHE|SSL_aRSA|SSL_AES|SSL_SHA|SSL_TLSV1,
  1301. SSL_NOT_EXP|SSL_HIGH,
  1302. 0,
  1303. 128,
  1304. 128,
  1305. SSL_ALL_CIPHERS,
  1306. SSL_ALL_STRENGTHS,
  1307. },
  1308. /* Cipher C014 */
  1309. {
  1310. 1,
  1311. TLS1_TXT_ECDHE_RSA_WITH_AES_256_CBC_SHA,
  1312. TLS1_CK_ECDHE_RSA_WITH_AES_256_CBC_SHA,
  1313. SSL_kECDHE|SSL_aRSA|SSL_AES|SSL_SHA|SSL_TLSV1,
  1314. SSL_NOT_EXP|SSL_HIGH,
  1315. 0,
  1316. 256,
  1317. 256,
  1318. SSL_ALL_CIPHERS,
  1319. SSL_ALL_STRENGTHS,
  1320. },
  1321. /* Cipher C015 */
  1322. {
  1323. 1,
  1324. TLS1_TXT_ECDH_anon_WITH_NULL_SHA,
  1325. TLS1_CK_ECDH_anon_WITH_NULL_SHA,
  1326. SSL_kECDHE|SSL_aNULL|SSL_eNULL|SSL_SHA|SSL_TLSV1,
  1327. SSL_NOT_EXP,
  1328. 0,
  1329. 0,
  1330. 0,
  1331. SSL_ALL_CIPHERS,
  1332. SSL_ALL_STRENGTHS,
  1333. },
  1334. /* Cipher C016 */
  1335. {
  1336. 1,
  1337. TLS1_TXT_ECDH_anon_WITH_RC4_128_SHA,
  1338. TLS1_CK_ECDH_anon_WITH_RC4_128_SHA,
  1339. SSL_kECDHE|SSL_aNULL|SSL_RC4|SSL_SHA|SSL_TLSV1,
  1340. SSL_NOT_EXP,
  1341. 0,
  1342. 128,
  1343. 128,
  1344. SSL_ALL_CIPHERS,
  1345. SSL_ALL_STRENGTHS,
  1346. },
  1347. /* Cipher C017 */
  1348. {
  1349. 1,
  1350. TLS1_TXT_ECDH_anon_WITH_DES_192_CBC3_SHA,
  1351. TLS1_CK_ECDH_anon_WITH_DES_192_CBC3_SHA,
  1352. SSL_kECDHE|SSL_aNULL|SSL_3DES|SSL_SHA|SSL_TLSV1,
  1353. SSL_NOT_EXP|SSL_HIGH,
  1354. 0,
  1355. 168,
  1356. 168,
  1357. SSL_ALL_CIPHERS,
  1358. SSL_ALL_STRENGTHS,
  1359. },
  1360. /* Cipher C018 */
  1361. {
  1362. 1,
  1363. TLS1_TXT_ECDH_anon_WITH_AES_128_CBC_SHA,
  1364. TLS1_CK_ECDH_anon_WITH_AES_128_CBC_SHA,
  1365. SSL_kECDHE|SSL_aNULL|SSL_AES|SSL_SHA|SSL_TLSV1,
  1366. SSL_NOT_EXP|SSL_HIGH,
  1367. 0,
  1368. 128,
  1369. 128,
  1370. SSL_ALL_CIPHERS,
  1371. SSL_ALL_STRENGTHS,
  1372. },
  1373. /* Cipher C019 */
  1374. {
  1375. 1,
  1376. TLS1_TXT_ECDH_anon_WITH_AES_256_CBC_SHA,
  1377. TLS1_CK_ECDH_anon_WITH_AES_256_CBC_SHA,
  1378. SSL_kECDHE|SSL_aNULL|SSL_AES|SSL_SHA|SSL_TLSV1,
  1379. SSL_NOT_EXP|SSL_HIGH,
  1380. 0,
  1381. 256,
  1382. 256,
  1383. SSL_ALL_CIPHERS,
  1384. SSL_ALL_STRENGTHS,
  1385. },
  1386. #endif /* OPENSSL_NO_ECDH */
  1387. /* end of list */
  1388. };
  1389. SSL3_ENC_METHOD SSLv3_enc_data={
  1390. ssl3_enc,
  1391. ssl3_mac,
  1392. ssl3_setup_key_block,
  1393. ssl3_generate_master_secret,
  1394. ssl3_change_cipher_state,
  1395. ssl3_final_finish_mac,
  1396. MD5_DIGEST_LENGTH+SHA_DIGEST_LENGTH,
  1397. ssl3_cert_verify_mac,
  1398. SSL3_MD_CLIENT_FINISHED_CONST,4,
  1399. SSL3_MD_SERVER_FINISHED_CONST,4,
  1400. ssl3_alert_code,
  1401. };
  1402. long ssl3_default_timeout(void)
  1403. {
  1404. /* 2 hours, the 24 hours mentioned in the SSLv3 spec
  1405. * is way too long for http, the cache would over fill */
  1406. return(60*60*2);
  1407. }
  1408. int ssl3_num_ciphers(void)
  1409. {
  1410. return(SSL3_NUM_CIPHERS);
  1411. }
  1412. SSL_CIPHER *ssl3_get_cipher(unsigned int u)
  1413. {
  1414. if (u < SSL3_NUM_CIPHERS)
  1415. return(&(ssl3_ciphers[SSL3_NUM_CIPHERS-1-u]));
  1416. else
  1417. return(NULL);
  1418. }
  1419. int ssl3_pending(const SSL *s)
  1420. {
  1421. if (s->rstate == SSL_ST_READ_BODY)
  1422. return 0;
  1423. return (s->s3->rrec.type == SSL3_RT_APPLICATION_DATA) ? s->s3->rrec.length : 0;
  1424. }
  1425. int ssl3_new(SSL *s)
  1426. {
  1427. SSL3_STATE *s3;
  1428. if ((s3=OPENSSL_malloc(sizeof *s3)) == NULL) goto err;
  1429. memset(s3,0,sizeof *s3);
  1430. EVP_MD_CTX_init(&s3->finish_dgst1);
  1431. EVP_MD_CTX_init(&s3->finish_dgst2);
  1432. memset(s3->rrec.seq_num,0,sizeof(s3->rrec.seq_num));
  1433. memset(s3->wrec.seq_num,0,sizeof(s3->wrec.seq_num));
  1434. s->s3=s3;
  1435. s->method->ssl_clear(s);
  1436. return(1);
  1437. err:
  1438. return(0);
  1439. }
  1440. void ssl3_free(SSL *s)
  1441. {
  1442. if(s == NULL)
  1443. return;
  1444. ssl3_cleanup_key_block(s);
  1445. if (s->s3->rbuf.buf != NULL)
  1446. OPENSSL_free(s->s3->rbuf.buf);
  1447. if (s->s3->wbuf.buf != NULL)
  1448. OPENSSL_free(s->s3->wbuf.buf);
  1449. if (s->s3->rrec.comp != NULL)
  1450. OPENSSL_free(s->s3->rrec.comp);
  1451. #ifndef OPENSSL_NO_DH
  1452. if (s->s3->tmp.dh != NULL)
  1453. DH_free(s->s3->tmp.dh);
  1454. #endif
  1455. #ifndef OPENSSL_NO_ECDH
  1456. if (s->s3->tmp.ecdh != NULL)
  1457. EC_KEY_free(s->s3->tmp.ecdh);
  1458. #endif
  1459. if (s->s3->tmp.ca_names != NULL)
  1460. sk_X509_NAME_pop_free(s->s3->tmp.ca_names,X509_NAME_free);
  1461. EVP_MD_CTX_cleanup(&s->s3->finish_dgst1);
  1462. EVP_MD_CTX_cleanup(&s->s3->finish_dgst2);
  1463. OPENSSL_cleanse(s->s3,sizeof *s->s3);
  1464. OPENSSL_free(s->s3);
  1465. s->s3=NULL;
  1466. }
  1467. void ssl3_clear(SSL *s)
  1468. {
  1469. unsigned char *rp,*wp;
  1470. size_t rlen, wlen;
  1471. ssl3_cleanup_key_block(s);
  1472. if (s->s3->tmp.ca_names != NULL)
  1473. sk_X509_NAME_pop_free(s->s3->tmp.ca_names,X509_NAME_free);
  1474. if (s->s3->rrec.comp != NULL)
  1475. {
  1476. OPENSSL_free(s->s3->rrec.comp);
  1477. s->s3->rrec.comp=NULL;
  1478. }
  1479. #ifndef OPENSSL_NO_DH
  1480. if (s->s3->tmp.dh != NULL)
  1481. DH_free(s->s3->tmp.dh);
  1482. #endif
  1483. #ifndef OPENSSL_NO_ECDH
  1484. if (s->s3->tmp.ecdh != NULL)
  1485. EC_KEY_free(s->s3->tmp.ecdh);
  1486. #endif
  1487. rp = s->s3->rbuf.buf;
  1488. wp = s->s3->wbuf.buf;
  1489. rlen = s->s3->rbuf.len;
  1490. wlen = s->s3->wbuf.len;
  1491. EVP_MD_CTX_cleanup(&s->s3->finish_dgst1);
  1492. EVP_MD_CTX_cleanup(&s->s3->finish_dgst2);
  1493. memset(s->s3,0,sizeof *s->s3);
  1494. s->s3->rbuf.buf = rp;
  1495. s->s3->wbuf.buf = wp;
  1496. s->s3->rbuf.len = rlen;
  1497. s->s3->wbuf.len = wlen;
  1498. ssl_free_wbio_buffer(s);
  1499. s->packet_length=0;
  1500. s->s3->renegotiate=0;
  1501. s->s3->total_renegotiations=0;
  1502. s->s3->num_renegotiations=0;
  1503. s->s3->in_read_app_data=0;
  1504. s->version=SSL3_VERSION;
  1505. }
  1506. long ssl3_ctrl(SSL *s, int cmd, long larg, void *parg)
  1507. {
  1508. int ret=0;
  1509. #if !defined(OPENSSL_NO_DSA) || !defined(OPENSSL_NO_RSA)
  1510. if (
  1511. #ifndef OPENSSL_NO_RSA
  1512. cmd == SSL_CTRL_SET_TMP_RSA ||
  1513. cmd == SSL_CTRL_SET_TMP_RSA_CB ||
  1514. #endif
  1515. #ifndef OPENSSL_NO_DSA
  1516. cmd == SSL_CTRL_SET_TMP_DH ||
  1517. cmd == SSL_CTRL_SET_TMP_DH_CB ||
  1518. #endif
  1519. 0)
  1520. {
  1521. if (!ssl_cert_inst(&s->cert))
  1522. {
  1523. SSLerr(SSL_F_SSL3_CTRL, ERR_R_MALLOC_FAILURE);
  1524. return(0);
  1525. }
  1526. }
  1527. #endif
  1528. switch (cmd)
  1529. {
  1530. case SSL_CTRL_GET_SESSION_REUSED:
  1531. ret=s->hit;
  1532. break;
  1533. case SSL_CTRL_GET_CLIENT_CERT_REQUEST:
  1534. break;
  1535. case SSL_CTRL_GET_NUM_RENEGOTIATIONS:
  1536. ret=s->s3->num_renegotiations;
  1537. break;
  1538. case SSL_CTRL_CLEAR_NUM_RENEGOTIATIONS:
  1539. ret=s->s3->num_renegotiations;
  1540. s->s3->num_renegotiations=0;
  1541. break;
  1542. case SSL_CTRL_GET_TOTAL_RENEGOTIATIONS:
  1543. ret=s->s3->total_renegotiations;
  1544. break;
  1545. case SSL_CTRL_GET_FLAGS:
  1546. ret=(int)(s->s3->flags);
  1547. break;
  1548. #ifndef OPENSSL_NO_RSA
  1549. case SSL_CTRL_NEED_TMP_RSA:
  1550. if ((s->cert != NULL) && (s->cert->rsa_tmp == NULL) &&
  1551. ((s->cert->pkeys[SSL_PKEY_RSA_ENC].privatekey == NULL) ||
  1552. (EVP_PKEY_size(s->cert->pkeys[SSL_PKEY_RSA_ENC].privatekey) > (512/8))))
  1553. ret = 1;
  1554. break;
  1555. case SSL_CTRL_SET_TMP_RSA:
  1556. {
  1557. RSA *rsa = (RSA *)parg;
  1558. if (rsa == NULL)
  1559. {
  1560. SSLerr(SSL_F_SSL3_CTRL, ERR_R_PASSED_NULL_PARAMETER);
  1561. return(ret);
  1562. }
  1563. if ((rsa = RSAPrivateKey_dup(rsa)) == NULL)
  1564. {
  1565. SSLerr(SSL_F_SSL3_CTRL, ERR_R_RSA_LIB);
  1566. return(ret);
  1567. }
  1568. if (s->cert->rsa_tmp != NULL)
  1569. RSA_free(s->cert->rsa_tmp);
  1570. s->cert->rsa_tmp = rsa;
  1571. ret = 1;
  1572. }
  1573. break;
  1574. case SSL_CTRL_SET_TMP_RSA_CB:
  1575. {
  1576. SSLerr(SSL_F_SSL3_CTRL, ERR_R_SHOULD_NOT_HAVE_BEEN_CALLED);
  1577. return(ret);
  1578. }
  1579. break;
  1580. #endif
  1581. #ifndef OPENSSL_NO_DH
  1582. case SSL_CTRL_SET_TMP_DH:
  1583. {
  1584. DH *dh = (DH *)parg;
  1585. if (dh == NULL)
  1586. {
  1587. SSLerr(SSL_F_SSL3_CTRL, ERR_R_PASSED_NULL_PARAMETER);
  1588. return(ret);
  1589. }
  1590. if ((dh = DHparams_dup(dh)) == NULL)
  1591. {
  1592. SSLerr(SSL_F_SSL3_CTRL, ERR_R_DH_LIB);
  1593. return(ret);
  1594. }
  1595. if (!(s->options & SSL_OP_SINGLE_DH_USE))
  1596. {
  1597. if (!DH_generate_key(dh))
  1598. {
  1599. DH_free(dh);
  1600. SSLerr(SSL_F_SSL3_CTRL, ERR_R_DH_LIB);
  1601. return(ret);
  1602. }
  1603. }
  1604. if (s->cert->dh_tmp != NULL)
  1605. DH_free(s->cert->dh_tmp);
  1606. s->cert->dh_tmp = dh;
  1607. ret = 1;
  1608. }
  1609. break;
  1610. case SSL_CTRL_SET_TMP_DH_CB:
  1611. {
  1612. SSLerr(SSL_F_SSL3_CTRL, ERR_R_SHOULD_NOT_HAVE_BEEN_CALLED);
  1613. return(ret);
  1614. }
  1615. break;
  1616. #endif
  1617. #ifndef OPENSSL_NO_ECDH
  1618. case SSL_CTRL_SET_TMP_ECDH:
  1619. {
  1620. EC_KEY *ecdh = NULL;
  1621. if (parg == NULL)
  1622. {
  1623. SSLerr(SSL_F_SSL3_CTRL, ERR_R_PASSED_NULL_PARAMETER);
  1624. return(ret);
  1625. }
  1626. if (!EC_KEY_up_ref((EC_KEY *)parg))
  1627. {
  1628. SSLerr(SSL_F_SSL3_CTRL,ERR_R_ECDH_LIB);
  1629. return(ret);
  1630. }
  1631. ecdh = (EC_KEY *)parg;
  1632. if (!(s->options & SSL_OP_SINGLE_ECDH_USE))
  1633. {
  1634. if (!EC_KEY_generate_key(ecdh))
  1635. {
  1636. EC_KEY_free(ecdh);
  1637. SSLerr(SSL_F_SSL3_CTRL,ERR_R_ECDH_LIB);
  1638. return(ret);
  1639. }
  1640. }
  1641. if (s->cert->ecdh_tmp != NULL)
  1642. EC_KEY_free(s->cert->ecdh_tmp);
  1643. s->cert->ecdh_tmp = ecdh;
  1644. ret = 1;
  1645. }
  1646. break;
  1647. case SSL_CTRL_SET_TMP_ECDH_CB:
  1648. {
  1649. SSLerr(SSL_F_SSL3_CTRL, ERR_R_SHOULD_NOT_HAVE_BEEN_CALLED);
  1650. return(ret);
  1651. }
  1652. break;
  1653. #endif /* !OPENSSL_NO_ECDH */
  1654. #ifndef OPENSSL_NO_TLSEXT
  1655. case SSL_CTRL_SET_TLSEXT_HOSTNAME:
  1656. if (larg == TLSEXT_NAMETYPE_host_name)
  1657. {
  1658. if (s->tlsext_hostname != NULL)
  1659. OPENSSL_free(s->tlsext_hostname);
  1660. s->tlsext_hostname = NULL;
  1661. ret = 1;
  1662. if (parg == NULL)
  1663. break;
  1664. if (strlen((char *)parg) > TLSEXT_MAXLEN_host_name)
  1665. {
  1666. SSLerr(SSL_F_SSL3_CTRL, SSL_R_SSL3_EXT_INVALID_SERVERNAME);
  1667. return 0;
  1668. }
  1669. if ((s->tlsext_hostname = BUF_strdup((char *)parg)) == NULL)
  1670. {
  1671. SSLerr(SSL_F_SSL3_CTRL, ERR_R_INTERNAL_ERROR);
  1672. return 0;
  1673. }
  1674. }
  1675. else
  1676. {
  1677. SSLerr(SSL_F_SSL3_CTRL, SSL_R_SSL3_EXT_INVALID_SERVERNAME_TYPE);
  1678. return 0;
  1679. }
  1680. s->options |= SSL_OP_NO_SSLv2; /* can't use extension w/ SSL 2.0 format */
  1681. break;
  1682. #endif /* !OPENSSL_NO_TLSEXT */
  1683. default:
  1684. break;
  1685. }
  1686. return(ret);
  1687. }
  1688. long ssl3_callback_ctrl(SSL *s, int cmd, void (*fp)(void))
  1689. {
  1690. int ret=0;
  1691. #if !defined(OPENSSL_NO_DSA) || !defined(OPENSSL_NO_RSA)
  1692. if (
  1693. #ifndef OPENSSL_NO_RSA
  1694. cmd == SSL_CTRL_SET_TMP_RSA_CB ||
  1695. #endif
  1696. #ifndef OPENSSL_NO_DSA
  1697. cmd == SSL_CTRL_SET_TMP_DH_CB ||
  1698. #endif
  1699. 0)
  1700. {
  1701. if (!ssl_cert_inst(&s->cert))
  1702. {
  1703. SSLerr(SSL_F_SSL3_CALLBACK_CTRL, ERR_R_MALLOC_FAILURE);
  1704. return(0);
  1705. }
  1706. }
  1707. #endif
  1708. switch (cmd)
  1709. {
  1710. #ifndef OPENSSL_NO_RSA
  1711. case SSL_CTRL_SET_TMP_RSA_CB:
  1712. {
  1713. s->cert->rsa_tmp_cb = (RSA *(*)(SSL *, int, int))fp;
  1714. }
  1715. break;
  1716. #endif
  1717. #ifndef OPENSSL_NO_DH
  1718. case SSL_CTRL_SET_TMP_DH_CB:
  1719. {
  1720. s->cert->dh_tmp_cb = (DH *(*)(SSL *, int, int))fp;
  1721. }
  1722. break;
  1723. #endif
  1724. #ifndef OPENSSL_NO_ECDH
  1725. case SSL_CTRL_SET_TMP_ECDH_CB:
  1726. {
  1727. s->cert->ecdh_tmp_cb = (EC_KEY *(*)(SSL *, int, int))fp;
  1728. }
  1729. break;
  1730. #endif
  1731. default:
  1732. break;
  1733. }
  1734. return(ret);
  1735. }
  1736. long ssl3_ctx_ctrl(SSL_CTX *ctx, int cmd, long larg, void *parg)
  1737. {
  1738. CERT *cert;
  1739. cert=ctx->cert;
  1740. switch (cmd)
  1741. {
  1742. #ifndef OPENSSL_NO_RSA
  1743. case SSL_CTRL_NEED_TMP_RSA:
  1744. if ( (cert->rsa_tmp == NULL) &&
  1745. ((cert->pkeys[SSL_PKEY_RSA_ENC].privatekey == NULL) ||
  1746. (EVP_PKEY_size(cert->pkeys[SSL_PKEY_RSA_ENC].privatekey) > (512/8)))
  1747. )
  1748. return(1);
  1749. else
  1750. return(0);
  1751. /* break; */
  1752. case SSL_CTRL_SET_TMP_RSA:
  1753. {
  1754. RSA *rsa;
  1755. int i;
  1756. rsa=(RSA *)parg;
  1757. i=1;
  1758. if (rsa == NULL)
  1759. i=0;
  1760. else
  1761. {
  1762. if ((rsa=RSAPrivateKey_dup(rsa)) == NULL)
  1763. i=0;
  1764. }
  1765. if (!i)
  1766. {
  1767. SSLerr(SSL_F_SSL3_CTX_CTRL,ERR_R_RSA_LIB);
  1768. return(0);
  1769. }
  1770. else
  1771. {
  1772. if (cert->rsa_tmp != NULL)
  1773. RSA_free(cert->rsa_tmp);
  1774. cert->rsa_tmp=rsa;
  1775. return(1);
  1776. }
  1777. }
  1778. /* break; */
  1779. case SSL_CTRL_SET_TMP_RSA_CB:
  1780. {
  1781. SSLerr(SSL_F_SSL3_CTX_CTRL, ERR_R_SHOULD_NOT_HAVE_BEEN_CALLED);
  1782. return(0);
  1783. }
  1784. break;
  1785. #endif
  1786. #ifndef OPENSSL_NO_DH
  1787. case SSL_CTRL_SET_TMP_DH:
  1788. {
  1789. DH *new=NULL,*dh;
  1790. dh=(DH *)parg;
  1791. if ((new=DHparams_dup(dh)) == NULL)
  1792. {
  1793. SSLerr(SSL_F_SSL3_CTX_CTRL,ERR_R_DH_LIB);
  1794. return 0;
  1795. }
  1796. if (!(ctx->options & SSL_OP_SINGLE_DH_USE))
  1797. {
  1798. if (!DH_generate_key(new))
  1799. {
  1800. SSLerr(SSL_F_SSL3_CTX_CTRL,ERR_R_DH_LIB);
  1801. DH_free(new);
  1802. return 0;
  1803. }
  1804. }
  1805. if (cert->dh_tmp != NULL)
  1806. DH_free(cert->dh_tmp);
  1807. cert->dh_tmp=new;
  1808. return 1;
  1809. }
  1810. /*break; */
  1811. case SSL_CTRL_SET_TMP_DH_CB:
  1812. {
  1813. SSLerr(SSL_F_SSL3_CTX_CTRL, ERR_R_SHOULD_NOT_HAVE_BEEN_CALLED);
  1814. return(0);
  1815. }
  1816. break;
  1817. #endif
  1818. #ifndef OPENSSL_NO_ECDH
  1819. case SSL_CTRL_SET_TMP_ECDH:
  1820. {
  1821. EC_KEY *ecdh = NULL;
  1822. if (parg == NULL)
  1823. {
  1824. SSLerr(SSL_F_SSL3_CTX_CTRL,ERR_R_ECDH_LIB);
  1825. return 0;
  1826. }
  1827. ecdh = EC_KEY_dup((EC_KEY *)parg);
  1828. if (ecdh == NULL)
  1829. {
  1830. SSLerr(SSL_F_SSL3_CTX_CTRL,ERR_R_EC_LIB);
  1831. return 0;
  1832. }
  1833. if (!(ctx->options & SSL_OP_SINGLE_ECDH_USE))
  1834. {
  1835. if (!EC_KEY_generate_key(ecdh))
  1836. {
  1837. EC_KEY_free(ecdh);
  1838. SSLerr(SSL_F_SSL3_CTX_CTRL,ERR_R_ECDH_LIB);
  1839. return 0;
  1840. }
  1841. }
  1842. if (cert->ecdh_tmp != NULL)
  1843. {
  1844. EC_KEY_free(cert->ecdh_tmp);
  1845. }
  1846. cert->ecdh_tmp = ecdh;
  1847. return 1;
  1848. }
  1849. /* break; */
  1850. case SSL_CTRL_SET_TMP_ECDH_CB:
  1851. {
  1852. SSLerr(SSL_F_SSL3_CTX_CTRL, ERR_R_SHOULD_NOT_HAVE_BEEN_CALLED);
  1853. return(0);
  1854. }
  1855. break;
  1856. #endif /* !OPENSSL_NO_ECDH */
  1857. #ifndef OPENSSL_NO_TLSEXT
  1858. case SSL_CTRL_SET_TLSEXT_SERVERNAME_ARG:
  1859. ctx->tlsext_servername_arg=parg;
  1860. break;
  1861. #endif /* !OPENSSL_NO_TLSEXT */
  1862. /* A Thawte special :-) */
  1863. case SSL_CTRL_EXTRA_CHAIN_CERT:
  1864. if (ctx->extra_certs == NULL)
  1865. {
  1866. if ((ctx->extra_certs=sk_X509_new_null()) == NULL)
  1867. return(0);
  1868. }
  1869. sk_X509_push(ctx->extra_certs,(X509 *)parg);
  1870. break;
  1871. default:
  1872. return(0);
  1873. }
  1874. return(1);
  1875. }
  1876. long ssl3_ctx_callback_ctrl(SSL_CTX *ctx, int cmd, void (*fp)(void))
  1877. {
  1878. CERT *cert;
  1879. cert=ctx->cert;
  1880. switch (cmd)
  1881. {
  1882. #ifndef OPENSSL_NO_RSA
  1883. case SSL_CTRL_SET_TMP_RSA_CB:
  1884. {
  1885. cert->rsa_tmp_cb = (RSA *(*)(SSL *, int, int))fp;
  1886. }
  1887. break;
  1888. #endif
  1889. #ifndef OPENSSL_NO_DH
  1890. case SSL_CTRL_SET_TMP_DH_CB:
  1891. {
  1892. cert->dh_tmp_cb = (DH *(*)(SSL *, int, int))fp;
  1893. }
  1894. break;
  1895. #endif
  1896. #ifndef OPENSSL_NO_ECDH
  1897. case SSL_CTRL_SET_TMP_ECDH_CB:
  1898. {
  1899. cert->ecdh_tmp_cb = (EC_KEY *(*)(SSL *, int, int))fp;
  1900. }
  1901. break;
  1902. #endif
  1903. #ifndef OPENSSL_NO_TLSEXT
  1904. case SSL_CTRL_SET_TLSEXT_SERVERNAME_CB:
  1905. ctx->tlsext_servername_callback=(int (*)(SSL *,int *,void *))fp;
  1906. break;
  1907. #endif
  1908. default:
  1909. return(0);
  1910. }
  1911. return(1);
  1912. }
  1913. /* This function needs to check if the ciphers required are actually
  1914. * available */
  1915. SSL_CIPHER *ssl3_get_cipher_by_char(const unsigned char *p)
  1916. {
  1917. SSL_CIPHER c,*cp;
  1918. unsigned long id;
  1919. id=0x03000000L|((unsigned long)p[0]<<8L)|(unsigned long)p[1];
  1920. c.id=id;
  1921. cp = (SSL_CIPHER *)OBJ_bsearch((char *)&c,
  1922. (char *)ssl3_ciphers,
  1923. SSL3_NUM_CIPHERS,sizeof(SSL_CIPHER),
  1924. FP_ICC ssl_cipher_id_cmp);
  1925. if (cp == NULL || cp->valid == 0)
  1926. return NULL;
  1927. else
  1928. return cp;
  1929. }
  1930. int ssl3_put_cipher_by_char(const SSL_CIPHER *c, unsigned char *p)
  1931. {
  1932. long l;
  1933. if (p != NULL)
  1934. {
  1935. l=c->id;
  1936. if ((l & 0xff000000) != 0x03000000) return(0);
  1937. p[0]=((unsigned char)(l>> 8L))&0xFF;
  1938. p[1]=((unsigned char)(l ))&0xFF;
  1939. }
  1940. return(2);
  1941. }
  1942. SSL_CIPHER *ssl3_choose_cipher(SSL *s, STACK_OF(SSL_CIPHER) *clnt,
  1943. STACK_OF(SSL_CIPHER) *srvr)
  1944. {
  1945. SSL_CIPHER *c,*ret=NULL;
  1946. STACK_OF(SSL_CIPHER) *prio, *allow;
  1947. int i,ok;
  1948. unsigned int j;
  1949. #ifndef OPENSSL_NO_TLSEXT
  1950. #ifndef OPENSSL_NO_EC
  1951. int ec_ok, ec_nid;
  1952. unsigned char ec_search1, ec_search2;
  1953. #endif /* OPENSSL_NO_EC */
  1954. #endif /* OPENSSL_NO_TLSEXT */
  1955. CERT *cert;
  1956. unsigned long alg,mask,emask;
  1957. /* Let's see which ciphers we can support */
  1958. cert=s->cert;
  1959. #if 0
  1960. /* Do not set the compare functions, because this may lead to a
  1961. * reordering by "id". We want to keep the original ordering.
  1962. * We may pay a price in performance during sk_SSL_CIPHER_find(),
  1963. * but would have to pay with the price of sk_SSL_CIPHER_dup().
  1964. */
  1965. sk_SSL_CIPHER_set_cmp_func(srvr, ssl_cipher_ptr_id_cmp);
  1966. sk_SSL_CIPHER_set_cmp_func(clnt, ssl_cipher_ptr_id_cmp);
  1967. #endif
  1968. #ifdef CIPHER_DEBUG
  1969. printf("Server has %d from %p:\n", sk_SSL_CIPHER_num(srvr), srvr);
  1970. for(i=0 ; i < sk_SSL_CIPHER_num(srvr) ; ++i)
  1971. {
  1972. c=sk_SSL_CIPHER_value(srvr,i);
  1973. printf("%p:%s\n",c,c->name);
  1974. }
  1975. printf("Client sent %d from %p:\n", sk_SSL_CIPHER_num(clnt), clnt);
  1976. for(i=0 ; i < sk_SSL_CIPHER_num(clnt) ; ++i)
  1977. {
  1978. c=sk_SSL_CIPHER_value(clnt,i);
  1979. printf("%p:%s\n",c,c->name);
  1980. }
  1981. #endif
  1982. if (s->options & SSL_OP_CIPHER_SERVER_PREFERENCE)
  1983. {
  1984. prio = srvr;
  1985. allow = clnt;
  1986. }
  1987. else
  1988. {
  1989. prio = clnt;
  1990. allow = srvr;
  1991. }
  1992. for (i=0; i<sk_SSL_CIPHER_num(prio); i++)
  1993. {
  1994. c=sk_SSL_CIPHER_value(prio,i);
  1995. ssl_set_cert_masks(cert,c);
  1996. mask=cert->mask;
  1997. emask=cert->export_mask;
  1998. #ifdef KSSL_DEBUG
  1999. printf("ssl3_choose_cipher %d alg= %lx\n", i,c->algorithms);
  2000. #endif /* KSSL_DEBUG */
  2001. alg=c->algorithms&(SSL_MKEY_MASK|SSL_AUTH_MASK);
  2002. #ifndef OPENSSL_NO_KRB5
  2003. if (alg & SSL_KRB5)
  2004. {
  2005. if ( !kssl_keytab_is_available(s->kssl_ctx) )
  2006. continue;
  2007. }
  2008. #endif /* OPENSSL_NO_KRB5 */
  2009. #ifndef OPENSSL_NO_PSK
  2010. /* with PSK there must be server callback set */
  2011. if ((alg & SSL_PSK) && s->psk_server_callback == NULL)
  2012. continue;
  2013. #endif /* OPENSSL_NO_PSK */
  2014. if (SSL_C_IS_EXPORT(c))
  2015. {
  2016. ok=((alg & emask) == alg)?1:0;
  2017. #ifdef CIPHER_DEBUG
  2018. printf("%d:[%08lX:%08lX]%p:%s (export)\n",ok,alg,emask,
  2019. c,c->name);
  2020. #endif
  2021. }
  2022. else
  2023. {
  2024. ok=((alg & mask) == alg)?1:0;
  2025. #ifdef CIPHER_DEBUG
  2026. printf("%d:[%08lX:%08lX]%p:%s\n",ok,alg,mask,c,
  2027. c->name);
  2028. #endif
  2029. }
  2030. #ifndef OPENSSL_NO_TLSEXT
  2031. #ifndef OPENSSL_NO_EC
  2032. if (
  2033. /* if we are considering an ECC cipher suite that uses our certificate */
  2034. (alg & SSL_aECDSA)
  2035. /* and we have an ECC certificate */
  2036. && (s->cert->pkeys[SSL_PKEY_ECC].x509 != NULL)
  2037. /* and the client specified a Supported Point Formats extension */
  2038. && ((s->session->tlsext_ecpointformatlist_length > 0) && (s->session->tlsext_ecpointformatlist != NULL))
  2039. /* and our certificate's point is compressed */
  2040. && (
  2041. (s->cert->pkeys[SSL_PKEY_ECC].x509->cert_info != NULL)
  2042. && (s->cert->pkeys[SSL_PKEY_ECC].x509->cert_info->key != NULL)
  2043. && (s->cert->pkeys[SSL_PKEY_ECC].x509->cert_info->key->public_key != NULL)
  2044. && (s->cert->pkeys[SSL_PKEY_ECC].x509->cert_info->key->public_key->data != NULL)
  2045. && (
  2046. (*(s->cert->pkeys[SSL_PKEY_ECC].x509->cert_info->key->public_key->data) == POINT_CONVERSION_COMPRESSED)
  2047. || (*(s->cert->pkeys[SSL_PKEY_ECC].x509->cert_info->key->public_key->data) == POINT_CONVERSION_COMPRESSED + 1)
  2048. )
  2049. )
  2050. )
  2051. {
  2052. ec_ok = 0;
  2053. /* if our certificate's curve is over a field type that the client does not support
  2054. * then do not allow this cipher suite to be negotiated */
  2055. if (
  2056. (s->cert->pkeys[SSL_PKEY_ECC].privatekey->pkey.ec != NULL)
  2057. && (s->cert->pkeys[SSL_PKEY_ECC].privatekey->pkey.ec->group != NULL)
  2058. && (s->cert->pkeys[SSL_PKEY_ECC].privatekey->pkey.ec->group->meth != NULL)
  2059. && (EC_METHOD_get_field_type(s->cert->pkeys[SSL_PKEY_ECC].privatekey->pkey.ec->group->meth) == NID_X9_62_prime_field)
  2060. )
  2061. {
  2062. for (j = 0; j < s->session->tlsext_ecpointformatlist_length; j++)
  2063. {
  2064. if (s->session->tlsext_ecpointformatlist[j] == TLSEXT_ECPOINTFORMAT_ansiX962_compressed_prime)
  2065. {
  2066. ec_ok = 1;
  2067. break;
  2068. }
  2069. }
  2070. }
  2071. else if (EC_METHOD_get_field_type(s->cert->pkeys[SSL_PKEY_ECC].privatekey->pkey.ec->group->meth) == NID_X9_62_characteristic_two_field)
  2072. {
  2073. for (j = 0; j < s->session->tlsext_ecpointformatlist_length; j++)
  2074. {
  2075. if (s->session->tlsext_ecpointformatlist[j] == TLSEXT_ECPOINTFORMAT_ansiX962_compressed_char2)
  2076. {
  2077. ec_ok = 1;
  2078. break;
  2079. }
  2080. }
  2081. }
  2082. ok = ok && ec_ok;
  2083. }
  2084. if (
  2085. /* if we are considering an ECC cipher suite that uses our certificate */
  2086. (alg & SSL_aECDSA)
  2087. /* and we have an ECC certificate */
  2088. && (s->cert->pkeys[SSL_PKEY_ECC].x509 != NULL)
  2089. /* and the client specified an EllipticCurves extension */
  2090. && ((s->session->tlsext_ellipticcurvelist_length > 0) && (s->session->tlsext_ellipticcurvelist != NULL))
  2091. )
  2092. {
  2093. ec_ok = 0;
  2094. if (
  2095. (s->cert->pkeys[SSL_PKEY_ECC].privatekey->pkey.ec != NULL)
  2096. && (s->cert->pkeys[SSL_PKEY_ECC].privatekey->pkey.ec->group != NULL)
  2097. )
  2098. {
  2099. ec_nid = EC_GROUP_get_curve_name(s->cert->pkeys[SSL_PKEY_ECC].privatekey->pkey.ec->group);
  2100. if ((ec_nid == 0)
  2101. && (s->cert->pkeys[SSL_PKEY_ECC].privatekey->pkey.ec->group->meth != NULL)
  2102. )
  2103. {
  2104. if (EC_METHOD_get_field_type(s->cert->pkeys[SSL_PKEY_ECC].privatekey->pkey.ec->group->meth) == NID_X9_62_prime_field)
  2105. {
  2106. ec_search1 = 0xFF;
  2107. ec_search2 = 0x01;
  2108. }
  2109. else if (EC_METHOD_get_field_type(s->cert->pkeys[SSL_PKEY_ECC].privatekey->pkey.ec->group->meth) == NID_X9_62_characteristic_two_field)
  2110. {
  2111. ec_search1 = 0xFF;
  2112. ec_search2 = 0x02;
  2113. }
  2114. }
  2115. else
  2116. {
  2117. ec_search1 = 0x00;
  2118. ec_search2 = tls1_ec_nid2curve_id(ec_nid);
  2119. }
  2120. if ((ec_search1 != 0) || (ec_search2 != 0))
  2121. {
  2122. for (j = 0; j < s->session->tlsext_ellipticcurvelist_length / 2; j++)
  2123. {
  2124. if ((s->session->tlsext_ellipticcurvelist[2*j] == ec_search1) && (s->session->tlsext_ellipticcurvelist[2*j+1] == ec_search2))
  2125. {
  2126. ec_ok = 1;
  2127. break;
  2128. }
  2129. }
  2130. }
  2131. }
  2132. ok = ok && ec_ok;
  2133. }
  2134. if (
  2135. /* if we are considering an ECC cipher suite that uses an ephemeral EC key */
  2136. ((alg & SSL_kECDH) || (alg & SSL_kECDHE))
  2137. /* and we have an ephemeral EC key */
  2138. && (s->cert->ecdh_tmp != NULL)
  2139. /* and the client specified an EllipticCurves extension */
  2140. && ((s->session->tlsext_ellipticcurvelist_length > 0) && (s->session->tlsext_ellipticcurvelist != NULL))
  2141. )
  2142. {
  2143. ec_ok = 0;
  2144. if (s->cert->ecdh_tmp->group != NULL)
  2145. {
  2146. ec_nid = EC_GROUP_get_curve_name(s->cert->ecdh_tmp->group);
  2147. if ((ec_nid == 0)
  2148. && (s->cert->ecdh_tmp->group->meth != NULL)
  2149. )
  2150. {
  2151. if (EC_METHOD_get_field_type(s->cert->ecdh_tmp->group->meth) == NID_X9_62_prime_field)
  2152. {
  2153. ec_search1 = 0xFF;
  2154. ec_search2 = 0x01;
  2155. }
  2156. else if (EC_METHOD_get_field_type(s->cert->ecdh_tmp->group->meth) == NID_X9_62_characteristic_two_field)
  2157. {
  2158. ec_search1 = 0xFF;
  2159. ec_search2 = 0x02;
  2160. }
  2161. }
  2162. else
  2163. {
  2164. ec_search1 = 0x00;
  2165. ec_search2 = tls1_ec_nid2curve_id(ec_nid);
  2166. }
  2167. if ((ec_search1 != 0) || (ec_search2 != 0))
  2168. {
  2169. for (j = 0; j < s->session->tlsext_ellipticcurvelist_length / 2; j++)
  2170. {
  2171. if ((s->session->tlsext_ellipticcurvelist[2*j] == ec_search1) && (s->session->tlsext_ellipticcurvelist[2*j+1] == ec_search2))
  2172. {
  2173. ec_ok = 1;
  2174. break;
  2175. }
  2176. }
  2177. }
  2178. }
  2179. ok = ok && ec_ok;
  2180. }
  2181. #endif /* OPENSSL_NO_EC */
  2182. #endif /* OPENSSL_NO_TLSEXT */
  2183. if (!ok) continue;
  2184. j=sk_SSL_CIPHER_find(allow,c);
  2185. if (j >= 0)
  2186. {
  2187. ret=sk_SSL_CIPHER_value(allow,j);
  2188. break;
  2189. }
  2190. }
  2191. return(ret);
  2192. }
  2193. int ssl3_get_req_cert_type(SSL *s, unsigned char *p)
  2194. {
  2195. int ret=0;
  2196. unsigned long alg;
  2197. alg=s->s3->tmp.new_cipher->algorithms;
  2198. #ifndef OPENSSL_NO_DH
  2199. if (alg & (SSL_kDHr|SSL_kEDH))
  2200. {
  2201. # ifndef OPENSSL_NO_RSA
  2202. p[ret++]=SSL3_CT_RSA_FIXED_DH;
  2203. # endif
  2204. # ifndef OPENSSL_NO_DSA
  2205. p[ret++]=SSL3_CT_DSS_FIXED_DH;
  2206. # endif
  2207. }
  2208. if ((s->version == SSL3_VERSION) &&
  2209. (alg & (SSL_kEDH|SSL_kDHd|SSL_kDHr)))
  2210. {
  2211. # ifndef OPENSSL_NO_RSA
  2212. p[ret++]=SSL3_CT_RSA_EPHEMERAL_DH;
  2213. # endif
  2214. # ifndef OPENSSL_NO_DSA
  2215. p[ret++]=SSL3_CT_DSS_EPHEMERAL_DH;
  2216. # endif
  2217. }
  2218. #endif /* !OPENSSL_NO_DH */
  2219. #ifndef OPENSSL_NO_RSA
  2220. p[ret++]=SSL3_CT_RSA_SIGN;
  2221. #endif
  2222. #ifndef OPENSSL_NO_DSA
  2223. p[ret++]=SSL3_CT_DSS_SIGN;
  2224. #endif
  2225. #ifndef OPENSSL_NO_ECDH
  2226. /* We should ask for fixed ECDH certificates only
  2227. * for SSL_kECDH (and not SSL_kECDHE)
  2228. */
  2229. if ((alg & SSL_kECDH) && (s->version >= TLS1_VERSION))
  2230. {
  2231. p[ret++]=TLS_CT_RSA_FIXED_ECDH;
  2232. p[ret++]=TLS_CT_ECDSA_FIXED_ECDH;
  2233. }
  2234. #endif
  2235. #ifndef OPENSSL_NO_ECDSA
  2236. /* ECDSA certs can be used with RSA cipher suites as well
  2237. * so we don't need to check for SSL_kECDH or SSL_kECDHE
  2238. */
  2239. if (s->version >= TLS1_VERSION)
  2240. {
  2241. p[ret++]=TLS_CT_ECDSA_SIGN;
  2242. }
  2243. #endif
  2244. return(ret);
  2245. }
  2246. int ssl3_shutdown(SSL *s)
  2247. {
  2248. /* Don't do anything much if we have not done the handshake or
  2249. * we don't want to send messages :-) */
  2250. if ((s->quiet_shutdown) || (s->state == SSL_ST_BEFORE))
  2251. {
  2252. s->shutdown=(SSL_SENT_SHUTDOWN|SSL_RECEIVED_SHUTDOWN);
  2253. return(1);
  2254. }
  2255. if (!(s->shutdown & SSL_SENT_SHUTDOWN))
  2256. {
  2257. s->shutdown|=SSL_SENT_SHUTDOWN;
  2258. #if 1
  2259. ssl3_send_alert(s,SSL3_AL_WARNING,SSL_AD_CLOSE_NOTIFY);
  2260. #endif
  2261. /* our shutdown alert has been sent now, and if it still needs
  2262. * to be written, s->s3->alert_dispatch will be true */
  2263. }
  2264. else if (s->s3->alert_dispatch)
  2265. {
  2266. /* resend it if not sent */
  2267. #if 1
  2268. s->method->ssl_dispatch_alert(s);
  2269. #endif
  2270. }
  2271. else if (!(s->shutdown & SSL_RECEIVED_SHUTDOWN))
  2272. {
  2273. /* If we are waiting for a close from our peer, we are closed */
  2274. s->method->ssl_read_bytes(s,0,NULL,0,0);
  2275. }
  2276. if ((s->shutdown == (SSL_SENT_SHUTDOWN|SSL_RECEIVED_SHUTDOWN)) &&
  2277. !s->s3->alert_dispatch)
  2278. return(1);
  2279. else
  2280. return(0);
  2281. }
  2282. int ssl3_write(SSL *s, const void *buf, int len)
  2283. {
  2284. int ret,n;
  2285. #if 0
  2286. if (s->shutdown & SSL_SEND_SHUTDOWN)
  2287. {
  2288. s->rwstate=SSL_NOTHING;
  2289. return(0);
  2290. }
  2291. #endif
  2292. clear_sys_error();
  2293. if (s->s3->renegotiate) ssl3_renegotiate_check(s);
  2294. /* This is an experimental flag that sends the
  2295. * last handshake message in the same packet as the first
  2296. * use data - used to see if it helps the TCP protocol during
  2297. * session-id reuse */
  2298. /* The second test is because the buffer may have been removed */
  2299. if ((s->s3->flags & SSL3_FLAGS_POP_BUFFER) && (s->wbio == s->bbio))
  2300. {
  2301. /* First time through, we write into the buffer */
  2302. if (s->s3->delay_buf_pop_ret == 0)
  2303. {
  2304. ret=ssl3_write_bytes(s,SSL3_RT_APPLICATION_DATA,
  2305. buf,len);
  2306. if (ret <= 0) return(ret);
  2307. s->s3->delay_buf_pop_ret=ret;
  2308. }
  2309. s->rwstate=SSL_WRITING;
  2310. n=BIO_flush(s->wbio);
  2311. if (n <= 0) return(n);
  2312. s->rwstate=SSL_NOTHING;
  2313. /* We have flushed the buffer, so remove it */
  2314. ssl_free_wbio_buffer(s);
  2315. s->s3->flags&= ~SSL3_FLAGS_POP_BUFFER;
  2316. ret=s->s3->delay_buf_pop_ret;
  2317. s->s3->delay_buf_pop_ret=0;
  2318. }
  2319. else
  2320. {
  2321. ret=s->method->ssl_write_bytes(s,SSL3_RT_APPLICATION_DATA,
  2322. buf,len);
  2323. if (ret <= 0) return(ret);
  2324. }
  2325. return(ret);
  2326. }
  2327. static int ssl3_read_internal(SSL *s, void *buf, int len, int peek)
  2328. {
  2329. int ret;
  2330. clear_sys_error();
  2331. if (s->s3->renegotiate) ssl3_renegotiate_check(s);
  2332. s->s3->in_read_app_data=1;
  2333. ret=s->method->ssl_read_bytes(s,SSL3_RT_APPLICATION_DATA,buf,len,peek);
  2334. if ((ret == -1) && (s->s3->in_read_app_data == 2))
  2335. {
  2336. /* ssl3_read_bytes decided to call s->handshake_func, which
  2337. * called ssl3_read_bytes to read handshake data.
  2338. * However, ssl3_read_bytes actually found application data
  2339. * and thinks that application data makes sense here; so disable
  2340. * handshake processing and try to read application data again. */
  2341. s->in_handshake++;
  2342. ret=s->method->ssl_read_bytes(s,SSL3_RT_APPLICATION_DATA,buf,len,peek);
  2343. s->in_handshake--;
  2344. }
  2345. else
  2346. s->s3->in_read_app_data=0;
  2347. return(ret);
  2348. }
  2349. int ssl3_read(SSL *s, void *buf, int len)
  2350. {
  2351. return ssl3_read_internal(s, buf, len, 0);
  2352. }
  2353. int ssl3_peek(SSL *s, void *buf, int len)
  2354. {
  2355. return ssl3_read_internal(s, buf, len, 1);
  2356. }
  2357. int ssl3_renegotiate(SSL *s)
  2358. {
  2359. if (s->handshake_func == NULL)
  2360. return(1);
  2361. if (s->s3->flags & SSL3_FLAGS_NO_RENEGOTIATE_CIPHERS)
  2362. return(0);
  2363. s->s3->renegotiate=1;
  2364. return(1);
  2365. }
  2366. int ssl3_renegotiate_check(SSL *s)
  2367. {
  2368. int ret=0;
  2369. if (s->s3->renegotiate)
  2370. {
  2371. if ( (s->s3->rbuf.left == 0) &&
  2372. (s->s3->wbuf.left == 0) &&
  2373. !SSL_in_init(s))
  2374. {
  2375. /*
  2376. if we are the server, and we have sent a 'RENEGOTIATE' message, we
  2377. need to go to SSL_ST_ACCEPT.
  2378. */
  2379. /* SSL_ST_ACCEPT */
  2380. s->state=SSL_ST_RENEGOTIATE;
  2381. s->s3->renegotiate=0;
  2382. s->s3->num_renegotiations++;
  2383. s->s3->total_renegotiations++;
  2384. ret=1;
  2385. }
  2386. }
  2387. return(ret);
  2388. }