s3_lib.c 63 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254325532563257325832593260326132623263326432653266326732683269327032713272327332743275327632773278327932803281328232833284328532863287328832893290329132923293329432953296329732983299330033013302330333043305
  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-2007 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,
  174. SSL_aRSA,
  175. SSL_eNULL,
  176. SSL_MD5,
  177. SSL_SSLV3,
  178. SSL_NOT_EXP|SSL_STRONG_NONE,
  179. SSL_HANDSHAKE_MAC_DEFAULT|TLS1_PRF,
  180. 0,
  181. 0,
  182. },
  183. /* Cipher 02 */
  184. {
  185. 1,
  186. SSL3_TXT_RSA_NULL_SHA,
  187. SSL3_CK_RSA_NULL_SHA,
  188. SSL_kRSA,
  189. SSL_aRSA,
  190. SSL_eNULL,
  191. SSL_SHA1,
  192. SSL_SSLV3,
  193. SSL_NOT_EXP|SSL_STRONG_NONE,
  194. SSL_HANDSHAKE_MAC_DEFAULT|TLS1_PRF,
  195. 0,
  196. 0,
  197. },
  198. /* Cipher 03 */
  199. {
  200. 1,
  201. SSL3_TXT_RSA_RC4_40_MD5,
  202. SSL3_CK_RSA_RC4_40_MD5,
  203. SSL_kRSA,
  204. SSL_aRSA,
  205. SSL_RC4,
  206. SSL_MD5,
  207. SSL_SSLV3,
  208. SSL_EXPORT|SSL_EXP40,
  209. SSL_HANDSHAKE_MAC_DEFAULT|TLS1_PRF,
  210. 40,
  211. 128,
  212. },
  213. /* Cipher 04 */
  214. {
  215. 1,
  216. SSL3_TXT_RSA_RC4_128_MD5,
  217. SSL3_CK_RSA_RC4_128_MD5,
  218. SSL_kRSA,
  219. SSL_aRSA,
  220. SSL_RC4,
  221. SSL_MD5,
  222. SSL_SSLV3,
  223. SSL_NOT_EXP|SSL_MEDIUM,
  224. SSL_HANDSHAKE_MAC_DEFAULT|TLS1_PRF,
  225. 128,
  226. 128,
  227. },
  228. /* Cipher 05 */
  229. {
  230. 1,
  231. SSL3_TXT_RSA_RC4_128_SHA,
  232. SSL3_CK_RSA_RC4_128_SHA,
  233. SSL_kRSA,
  234. SSL_aRSA,
  235. SSL_RC4,
  236. SSL_SHA1,
  237. SSL_SSLV3,
  238. SSL_NOT_EXP|SSL_MEDIUM,
  239. SSL_HANDSHAKE_MAC_DEFAULT|TLS1_PRF,
  240. 128,
  241. 128,
  242. },
  243. /* Cipher 06 */
  244. {
  245. 1,
  246. SSL3_TXT_RSA_RC2_40_MD5,
  247. SSL3_CK_RSA_RC2_40_MD5,
  248. SSL_kRSA,
  249. SSL_aRSA,
  250. SSL_RC2,
  251. SSL_MD5,
  252. SSL_SSLV3,
  253. SSL_EXPORT|SSL_EXP40,
  254. SSL_HANDSHAKE_MAC_DEFAULT|TLS1_PRF,
  255. 40,
  256. 128,
  257. },
  258. /* Cipher 07 */
  259. #ifndef OPENSSL_NO_IDEA
  260. {
  261. 1,
  262. SSL3_TXT_RSA_IDEA_128_SHA,
  263. SSL3_CK_RSA_IDEA_128_SHA,
  264. SSL_kRSA,
  265. SSL_aRSA,
  266. SSL_IDEA,
  267. SSL_SHA1,
  268. SSL_SSLV3,
  269. SSL_NOT_EXP|SSL_MEDIUM,
  270. SSL_HANDSHAKE_MAC_DEFAULT|TLS1_PRF,
  271. 128,
  272. 128,
  273. },
  274. #endif
  275. /* Cipher 08 */
  276. {
  277. 1,
  278. SSL3_TXT_RSA_DES_40_CBC_SHA,
  279. SSL3_CK_RSA_DES_40_CBC_SHA,
  280. SSL_kRSA,
  281. SSL_aRSA,
  282. SSL_DES,
  283. SSL_SHA1,
  284. SSL_SSLV3,
  285. SSL_EXPORT|SSL_EXP40,
  286. SSL_HANDSHAKE_MAC_DEFAULT|TLS1_PRF,
  287. 40,
  288. 56,
  289. },
  290. /* Cipher 09 */
  291. {
  292. 1,
  293. SSL3_TXT_RSA_DES_64_CBC_SHA,
  294. SSL3_CK_RSA_DES_64_CBC_SHA,
  295. SSL_kRSA,
  296. SSL_aRSA,
  297. SSL_DES,
  298. SSL_SHA1,
  299. SSL_SSLV3,
  300. SSL_NOT_EXP|SSL_LOW,
  301. SSL_HANDSHAKE_MAC_DEFAULT|TLS1_PRF,
  302. 56,
  303. 56,
  304. },
  305. /* Cipher 0A */
  306. {
  307. 1,
  308. SSL3_TXT_RSA_DES_192_CBC3_SHA,
  309. SSL3_CK_RSA_DES_192_CBC3_SHA,
  310. SSL_kRSA,
  311. SSL_aRSA,
  312. SSL_3DES,
  313. SSL_SHA1,
  314. SSL_SSLV3,
  315. SSL_NOT_EXP|SSL_HIGH,
  316. SSL_HANDSHAKE_MAC_DEFAULT|TLS1_PRF,
  317. 168,
  318. 168,
  319. },
  320. /* The DH ciphers */
  321. /* Cipher 0B */
  322. {
  323. 0,
  324. SSL3_TXT_DH_DSS_DES_40_CBC_SHA,
  325. SSL3_CK_DH_DSS_DES_40_CBC_SHA,
  326. SSL_kDHd,
  327. SSL_aDH,
  328. SSL_DES,
  329. SSL_SHA1,
  330. SSL_SSLV3,
  331. SSL_EXPORT|SSL_EXP40,
  332. SSL_HANDSHAKE_MAC_DEFAULT|TLS1_PRF,
  333. 40,
  334. 56,
  335. },
  336. /* Cipher 0C */
  337. {
  338. 0, /* not implemented (non-ephemeral DH) */
  339. SSL3_TXT_DH_DSS_DES_64_CBC_SHA,
  340. SSL3_CK_DH_DSS_DES_64_CBC_SHA,
  341. SSL_kDHd,
  342. SSL_aDH,
  343. SSL_DES,
  344. SSL_SHA1,
  345. SSL_SSLV3,
  346. SSL_NOT_EXP|SSL_LOW,
  347. SSL_HANDSHAKE_MAC_DEFAULT|TLS1_PRF,
  348. 56,
  349. 56,
  350. },
  351. /* Cipher 0D */
  352. {
  353. 0, /* not implemented (non-ephemeral DH) */
  354. SSL3_TXT_DH_DSS_DES_192_CBC3_SHA,
  355. SSL3_CK_DH_DSS_DES_192_CBC3_SHA,
  356. SSL_kDHd,
  357. SSL_aDH,
  358. SSL_3DES,
  359. SSL_SHA1,
  360. SSL_SSLV3,
  361. SSL_NOT_EXP|SSL_HIGH,
  362. SSL_HANDSHAKE_MAC_DEFAULT|TLS1_PRF,
  363. 168,
  364. 168,
  365. },
  366. /* Cipher 0E */
  367. {
  368. 0, /* not implemented (non-ephemeral DH) */
  369. SSL3_TXT_DH_RSA_DES_40_CBC_SHA,
  370. SSL3_CK_DH_RSA_DES_40_CBC_SHA,
  371. SSL_kDHr,
  372. SSL_aDH,
  373. SSL_DES,
  374. SSL_SHA1,
  375. SSL_SSLV3,
  376. SSL_EXPORT|SSL_EXP40,
  377. SSL_HANDSHAKE_MAC_DEFAULT|TLS1_PRF,
  378. 40,
  379. 56,
  380. },
  381. /* Cipher 0F */
  382. {
  383. 0, /* not implemented (non-ephemeral DH) */
  384. SSL3_TXT_DH_RSA_DES_64_CBC_SHA,
  385. SSL3_CK_DH_RSA_DES_64_CBC_SHA,
  386. SSL_kDHr,
  387. SSL_aDH,
  388. SSL_DES,
  389. SSL_SHA1,
  390. SSL_SSLV3,
  391. SSL_NOT_EXP|SSL_LOW,
  392. SSL_HANDSHAKE_MAC_DEFAULT|TLS1_PRF,
  393. 56,
  394. 56,
  395. },
  396. /* Cipher 10 */
  397. {
  398. 0, /* not implemented (non-ephemeral DH) */
  399. SSL3_TXT_DH_RSA_DES_192_CBC3_SHA,
  400. SSL3_CK_DH_RSA_DES_192_CBC3_SHA,
  401. SSL_kDHr,
  402. SSL_aDH,
  403. SSL_3DES,
  404. SSL_SHA1,
  405. SSL_SSLV3,
  406. SSL_NOT_EXP|SSL_HIGH,
  407. SSL_HANDSHAKE_MAC_DEFAULT|TLS1_PRF,
  408. 168,
  409. 168,
  410. },
  411. /* The Ephemeral DH ciphers */
  412. /* Cipher 11 */
  413. {
  414. 1,
  415. SSL3_TXT_EDH_DSS_DES_40_CBC_SHA,
  416. SSL3_CK_EDH_DSS_DES_40_CBC_SHA,
  417. SSL_kEDH,
  418. SSL_aDSS,
  419. SSL_DES,
  420. SSL_SHA1,
  421. SSL_SSLV3,
  422. SSL_EXPORT|SSL_EXP40,
  423. SSL_HANDSHAKE_MAC_DEFAULT|TLS1_PRF,
  424. 40,
  425. 56,
  426. },
  427. /* Cipher 12 */
  428. {
  429. 1,
  430. SSL3_TXT_EDH_DSS_DES_64_CBC_SHA,
  431. SSL3_CK_EDH_DSS_DES_64_CBC_SHA,
  432. SSL_kEDH,
  433. SSL_aDSS,
  434. SSL_DES,
  435. SSL_SHA1,
  436. SSL_SSLV3,
  437. SSL_NOT_EXP|SSL_LOW,
  438. SSL_HANDSHAKE_MAC_DEFAULT|TLS1_PRF,
  439. 56,
  440. 56,
  441. },
  442. /* Cipher 13 */
  443. {
  444. 1,
  445. SSL3_TXT_EDH_DSS_DES_192_CBC3_SHA,
  446. SSL3_CK_EDH_DSS_DES_192_CBC3_SHA,
  447. SSL_kEDH,
  448. SSL_aDSS,
  449. SSL_3DES,
  450. SSL_SHA1,
  451. SSL_SSLV3,
  452. SSL_NOT_EXP|SSL_HIGH,
  453. SSL_HANDSHAKE_MAC_DEFAULT|TLS1_PRF,
  454. 168,
  455. 168,
  456. },
  457. /* Cipher 14 */
  458. {
  459. 1,
  460. SSL3_TXT_EDH_RSA_DES_40_CBC_SHA,
  461. SSL3_CK_EDH_RSA_DES_40_CBC_SHA,
  462. SSL_kEDH,
  463. SSL_aRSA,
  464. SSL_DES,
  465. SSL_SHA1,
  466. SSL_SSLV3,
  467. SSL_EXPORT|SSL_EXP40,
  468. SSL_HANDSHAKE_MAC_DEFAULT|TLS1_PRF,
  469. 40,
  470. 56,
  471. },
  472. /* Cipher 15 */
  473. {
  474. 1,
  475. SSL3_TXT_EDH_RSA_DES_64_CBC_SHA,
  476. SSL3_CK_EDH_RSA_DES_64_CBC_SHA,
  477. SSL_kEDH,
  478. SSL_aRSA,
  479. SSL_DES,
  480. SSL_SHA1,
  481. SSL_SSLV3,
  482. SSL_NOT_EXP|SSL_LOW,
  483. SSL_HANDSHAKE_MAC_DEFAULT|TLS1_PRF,
  484. 56,
  485. 56,
  486. },
  487. /* Cipher 16 */
  488. {
  489. 1,
  490. SSL3_TXT_EDH_RSA_DES_192_CBC3_SHA,
  491. SSL3_CK_EDH_RSA_DES_192_CBC3_SHA,
  492. SSL_kEDH,
  493. SSL_aRSA,
  494. SSL_3DES,
  495. SSL_SHA1,
  496. SSL_SSLV3,
  497. SSL_NOT_EXP|SSL_HIGH,
  498. SSL_HANDSHAKE_MAC_DEFAULT|TLS1_PRF,
  499. 168,
  500. 168,
  501. },
  502. /* Cipher 17 */
  503. {
  504. 1,
  505. SSL3_TXT_ADH_RC4_40_MD5,
  506. SSL3_CK_ADH_RC4_40_MD5,
  507. SSL_kEDH,
  508. SSL_aNULL,
  509. SSL_RC4,
  510. SSL_MD5,
  511. SSL_SSLV3,
  512. SSL_EXPORT|SSL_EXP40,
  513. SSL_HANDSHAKE_MAC_DEFAULT|TLS1_PRF,
  514. 40,
  515. 128,
  516. },
  517. /* Cipher 18 */
  518. {
  519. 1,
  520. SSL3_TXT_ADH_RC4_128_MD5,
  521. SSL3_CK_ADH_RC4_128_MD5,
  522. SSL_kEDH,
  523. SSL_aNULL,
  524. SSL_RC4,
  525. SSL_MD5,
  526. SSL_SSLV3,
  527. SSL_NOT_EXP|SSL_MEDIUM,
  528. SSL_HANDSHAKE_MAC_DEFAULT|TLS1_PRF,
  529. 128,
  530. 128,
  531. },
  532. /* Cipher 19 */
  533. {
  534. 1,
  535. SSL3_TXT_ADH_DES_40_CBC_SHA,
  536. SSL3_CK_ADH_DES_40_CBC_SHA,
  537. SSL_kEDH,
  538. SSL_aNULL,
  539. SSL_DES,
  540. SSL_SHA1,
  541. SSL_SSLV3,
  542. SSL_EXPORT|SSL_EXP40,
  543. SSL_HANDSHAKE_MAC_DEFAULT|TLS1_PRF,
  544. 40,
  545. 128,
  546. },
  547. /* Cipher 1A */
  548. {
  549. 1,
  550. SSL3_TXT_ADH_DES_64_CBC_SHA,
  551. SSL3_CK_ADH_DES_64_CBC_SHA,
  552. SSL_kEDH,
  553. SSL_aNULL,
  554. SSL_DES,
  555. SSL_SHA1,
  556. SSL_SSLV3,
  557. SSL_NOT_EXP|SSL_LOW,
  558. SSL_HANDSHAKE_MAC_DEFAULT|TLS1_PRF,
  559. 56,
  560. 56,
  561. },
  562. /* Cipher 1B */
  563. {
  564. 1,
  565. SSL3_TXT_ADH_DES_192_CBC_SHA,
  566. SSL3_CK_ADH_DES_192_CBC_SHA,
  567. SSL_kEDH,
  568. SSL_aNULL,
  569. SSL_3DES,
  570. SSL_SHA1,
  571. SSL_SSLV3,
  572. SSL_NOT_EXP|SSL_HIGH,
  573. SSL_HANDSHAKE_MAC_DEFAULT|TLS1_PRF,
  574. 168,
  575. 168,
  576. },
  577. /* Fortezza ciphersuite from SSL 3.0 spec */
  578. #if 0
  579. /* Cipher 1C */
  580. {
  581. 0,
  582. SSL3_TXT_FZA_DMS_NULL_SHA,
  583. SSL3_CK_FZA_DMS_NULL_SHA,
  584. SSL_kFZA,
  585. SSL_aFZA,
  586. SSL_eNULL,
  587. SSL_SHA1,
  588. SSL_SSLV3,
  589. SSL_NOT_EXP|SSL_STRONG_NONE,
  590. SSL_HANDSHAKE_MAC_DEFAULT|TLS1_PRF,
  591. 0,
  592. 0,
  593. },
  594. /* Cipher 1D */
  595. {
  596. 0,
  597. SSL3_TXT_FZA_DMS_FZA_SHA,
  598. SSL3_CK_FZA_DMS_FZA_SHA,
  599. SSL_kFZA,
  600. SSL_aFZA,
  601. SSL_eFZA,
  602. SSL_SHA1,
  603. SSL_SSLV3,
  604. SSL_NOT_EXP|SSL_STRONG_NONE,
  605. SSL_HANDSHAKE_MAC_DEFAULT|TLS1_PRF,
  606. 0,
  607. 0,
  608. },
  609. /* Cipher 1E */
  610. {
  611. 0,
  612. SSL3_TXT_FZA_DMS_RC4_SHA,
  613. SSL3_CK_FZA_DMS_RC4_SHA,
  614. SSL_kFZA,
  615. SSL_aFZA,
  616. SSL_RC4,
  617. SSL_SHA1,
  618. SSL_SSLV3,
  619. SSL_NOT_EXP|SSL_MEDIUM,
  620. SSL_HANDSHAKE_MAC_DEFAULT|TLS1_PRF,
  621. 128,
  622. 128,
  623. },
  624. #endif
  625. #ifndef OPENSSL_NO_KRB5
  626. /* The Kerberos ciphers*/
  627. /* Cipher 1E */
  628. {
  629. 1,
  630. SSL3_TXT_KRB5_DES_64_CBC_SHA,
  631. SSL3_CK_KRB5_DES_64_CBC_SHA,
  632. SSL_kKRB5,
  633. SSL_aKRB5,
  634. SSL_DES,
  635. SSL_SHA1,
  636. SSL_SSLV3,
  637. SSL_NOT_EXP|SSL_LOW,
  638. SSL_HANDSHAKE_MAC_DEFAULT|TLS1_PRF,
  639. 56,
  640. 56,
  641. },
  642. /* Cipher 1F */
  643. {
  644. 1,
  645. SSL3_TXT_KRB5_DES_192_CBC3_SHA,
  646. SSL3_CK_KRB5_DES_192_CBC3_SHA,
  647. SSL_kKRB5,
  648. SSL_aKRB5,
  649. SSL_3DES,
  650. SSL_SHA1,
  651. SSL_SSLV3,
  652. SSL_NOT_EXP|SSL_HIGH,
  653. SSL_HANDSHAKE_MAC_DEFAULT|TLS1_PRF,
  654. 168,
  655. 168,
  656. },
  657. /* Cipher 20 */
  658. {
  659. 1,
  660. SSL3_TXT_KRB5_RC4_128_SHA,
  661. SSL3_CK_KRB5_RC4_128_SHA,
  662. SSL_kKRB5,
  663. SSL_aKRB5,
  664. SSL_RC4,
  665. SSL_SHA1,
  666. SSL_SSLV3,
  667. SSL_NOT_EXP|SSL_MEDIUM,
  668. SSL_HANDSHAKE_MAC_DEFAULT|TLS1_PRF,
  669. 128,
  670. 128,
  671. },
  672. /* Cipher 21 */
  673. {
  674. 1,
  675. SSL3_TXT_KRB5_IDEA_128_CBC_SHA,
  676. SSL3_CK_KRB5_IDEA_128_CBC_SHA,
  677. SSL_kKRB5,
  678. SSL_aKRB5,
  679. SSL_IDEA,
  680. SSL_SHA1,
  681. SSL_SSLV3,
  682. SSL_NOT_EXP|SSL_MEDIUM,
  683. SSL_HANDSHAKE_MAC_DEFAULT|TLS1_PRF,
  684. 128,
  685. 128,
  686. },
  687. /* Cipher 22 */
  688. {
  689. 1,
  690. SSL3_TXT_KRB5_DES_64_CBC_MD5,
  691. SSL3_CK_KRB5_DES_64_CBC_MD5,
  692. SSL_kKRB5,
  693. SSL_aKRB5,
  694. SSL_DES,
  695. SSL_MD5,
  696. SSL_SSLV3,
  697. SSL_NOT_EXP|SSL_LOW,
  698. SSL_HANDSHAKE_MAC_DEFAULT|TLS1_PRF,
  699. 56,
  700. 56,
  701. },
  702. /* Cipher 23 */
  703. {
  704. 1,
  705. SSL3_TXT_KRB5_DES_192_CBC3_MD5,
  706. SSL3_CK_KRB5_DES_192_CBC3_MD5,
  707. SSL_kKRB5,
  708. SSL_aKRB5,
  709. SSL_3DES,
  710. SSL_MD5,
  711. SSL_SSLV3,
  712. SSL_NOT_EXP|SSL_HIGH,
  713. SSL_HANDSHAKE_MAC_DEFAULT|TLS1_PRF,
  714. 168,
  715. 168,
  716. },
  717. /* Cipher 24 */
  718. {
  719. 1,
  720. SSL3_TXT_KRB5_RC4_128_MD5,
  721. SSL3_CK_KRB5_RC4_128_MD5,
  722. SSL_kKRB5,
  723. SSL_aKRB5,
  724. SSL_RC4,
  725. SSL_MD5,
  726. SSL_SSLV3,
  727. SSL_NOT_EXP|SSL_MEDIUM,
  728. SSL_HANDSHAKE_MAC_DEFAULT|TLS1_PRF,
  729. 128,
  730. 128,
  731. },
  732. /* Cipher 25 */
  733. {
  734. 1,
  735. SSL3_TXT_KRB5_IDEA_128_CBC_MD5,
  736. SSL3_CK_KRB5_IDEA_128_CBC_MD5,
  737. SSL_kKRB5,
  738. SSL_aKRB5,
  739. SSL_IDEA,
  740. SSL_MD5,
  741. SSL_SSLV3,
  742. SSL_NOT_EXP|SSL_MEDIUM,
  743. SSL_HANDSHAKE_MAC_DEFAULT|TLS1_PRF,
  744. 128,
  745. 128,
  746. },
  747. /* Cipher 26 */
  748. {
  749. 1,
  750. SSL3_TXT_KRB5_DES_40_CBC_SHA,
  751. SSL3_CK_KRB5_DES_40_CBC_SHA,
  752. SSL_kKRB5,
  753. SSL_aKRB5,
  754. SSL_DES,
  755. SSL_SHA1,
  756. SSL_SSLV3,
  757. SSL_EXPORT|SSL_EXP40,
  758. SSL_HANDSHAKE_MAC_DEFAULT|TLS1_PRF,
  759. 40,
  760. 56,
  761. },
  762. /* Cipher 27 */
  763. {
  764. 1,
  765. SSL3_TXT_KRB5_RC2_40_CBC_SHA,
  766. SSL3_CK_KRB5_RC2_40_CBC_SHA,
  767. SSL_kKRB5,
  768. SSL_aKRB5,
  769. SSL_RC2,
  770. SSL_SHA1,
  771. SSL_SSLV3,
  772. SSL_EXPORT|SSL_EXP40,
  773. SSL_HANDSHAKE_MAC_DEFAULT|TLS1_PRF,
  774. 40,
  775. 128,
  776. },
  777. /* Cipher 28 */
  778. {
  779. 1,
  780. SSL3_TXT_KRB5_RC4_40_SHA,
  781. SSL3_CK_KRB5_RC4_40_SHA,
  782. SSL_kKRB5,
  783. SSL_aKRB5,
  784. SSL_RC4,
  785. SSL_SHA1,
  786. SSL_SSLV3,
  787. SSL_EXPORT|SSL_EXP40,
  788. SSL_HANDSHAKE_MAC_DEFAULT|TLS1_PRF,
  789. 40,
  790. 128,
  791. },
  792. /* Cipher 29 */
  793. {
  794. 1,
  795. SSL3_TXT_KRB5_DES_40_CBC_MD5,
  796. SSL3_CK_KRB5_DES_40_CBC_MD5,
  797. SSL_kKRB5,
  798. SSL_aKRB5,
  799. SSL_DES,
  800. SSL_MD5,
  801. SSL_SSLV3,
  802. SSL_EXPORT|SSL_EXP40,
  803. SSL_HANDSHAKE_MAC_DEFAULT|TLS1_PRF,
  804. 40,
  805. 56,
  806. },
  807. /* Cipher 2A */
  808. {
  809. 1,
  810. SSL3_TXT_KRB5_RC2_40_CBC_MD5,
  811. SSL3_CK_KRB5_RC2_40_CBC_MD5,
  812. SSL_kKRB5,
  813. SSL_aKRB5,
  814. SSL_RC2,
  815. SSL_MD5,
  816. SSL_SSLV3,
  817. SSL_EXPORT|SSL_EXP40,
  818. SSL_HANDSHAKE_MAC_DEFAULT|TLS1_PRF,
  819. 40,
  820. 128,
  821. },
  822. /* Cipher 2B */
  823. {
  824. 1,
  825. SSL3_TXT_KRB5_RC4_40_MD5,
  826. SSL3_CK_KRB5_RC4_40_MD5,
  827. SSL_kKRB5,
  828. SSL_aKRB5,
  829. SSL_RC4,
  830. SSL_MD5,
  831. SSL_SSLV3,
  832. SSL_EXPORT|SSL_EXP40,
  833. SSL_HANDSHAKE_MAC_DEFAULT|TLS1_PRF,
  834. 40,
  835. 128,
  836. },
  837. #endif /* OPENSSL_NO_KRB5 */
  838. /* New AES ciphersuites */
  839. /* Cipher 2F */
  840. {
  841. 1,
  842. TLS1_TXT_RSA_WITH_AES_128_SHA,
  843. TLS1_CK_RSA_WITH_AES_128_SHA,
  844. SSL_kRSA,
  845. SSL_aRSA,
  846. SSL_AES128,
  847. SSL_SHA1,
  848. SSL_TLSV1,
  849. SSL_NOT_EXP|SSL_HIGH,
  850. SSL_HANDSHAKE_MAC_DEFAULT|TLS1_PRF,
  851. 128,
  852. 128,
  853. },
  854. /* Cipher 30 */
  855. {
  856. 0,
  857. TLS1_TXT_DH_DSS_WITH_AES_128_SHA,
  858. TLS1_CK_DH_DSS_WITH_AES_128_SHA,
  859. SSL_kDHd,
  860. SSL_aDH,
  861. SSL_AES128,
  862. SSL_SHA1,
  863. SSL_TLSV1,
  864. SSL_NOT_EXP|SSL_HIGH,
  865. SSL_HANDSHAKE_MAC_DEFAULT|TLS1_PRF,
  866. 128,
  867. 128,
  868. },
  869. /* Cipher 31 */
  870. {
  871. 0,
  872. TLS1_TXT_DH_RSA_WITH_AES_128_SHA,
  873. TLS1_CK_DH_RSA_WITH_AES_128_SHA,
  874. SSL_kDHr,
  875. SSL_aDH,
  876. SSL_AES128,
  877. SSL_SHA1,
  878. SSL_TLSV1,
  879. SSL_NOT_EXP|SSL_HIGH,
  880. SSL_HANDSHAKE_MAC_DEFAULT|TLS1_PRF,
  881. 128,
  882. 128,
  883. },
  884. /* Cipher 32 */
  885. {
  886. 1,
  887. TLS1_TXT_DHE_DSS_WITH_AES_128_SHA,
  888. TLS1_CK_DHE_DSS_WITH_AES_128_SHA,
  889. SSL_kEDH,
  890. SSL_aDSS,
  891. SSL_AES128,
  892. SSL_SHA1,
  893. SSL_TLSV1,
  894. SSL_NOT_EXP|SSL_HIGH,
  895. SSL_HANDSHAKE_MAC_DEFAULT|TLS1_PRF,
  896. 128,
  897. 128,
  898. },
  899. /* Cipher 33 */
  900. {
  901. 1,
  902. TLS1_TXT_DHE_RSA_WITH_AES_128_SHA,
  903. TLS1_CK_DHE_RSA_WITH_AES_128_SHA,
  904. SSL_kEDH,
  905. SSL_aRSA,
  906. SSL_AES128,
  907. SSL_SHA1,
  908. SSL_TLSV1,
  909. SSL_NOT_EXP|SSL_HIGH,
  910. SSL_HANDSHAKE_MAC_DEFAULT|TLS1_PRF,
  911. 128,
  912. 128,
  913. },
  914. /* Cipher 34 */
  915. {
  916. 1,
  917. TLS1_TXT_ADH_WITH_AES_128_SHA,
  918. TLS1_CK_ADH_WITH_AES_128_SHA,
  919. SSL_kEDH,
  920. SSL_aNULL,
  921. SSL_AES128,
  922. SSL_SHA1,
  923. SSL_TLSV1,
  924. SSL_NOT_EXP|SSL_HIGH,
  925. SSL_HANDSHAKE_MAC_DEFAULT|TLS1_PRF,
  926. 128,
  927. 128,
  928. },
  929. /* Cipher 35 */
  930. {
  931. 1,
  932. TLS1_TXT_RSA_WITH_AES_256_SHA,
  933. TLS1_CK_RSA_WITH_AES_256_SHA,
  934. SSL_kRSA,
  935. SSL_aRSA,
  936. SSL_AES256,
  937. SSL_SHA1,
  938. SSL_TLSV1,
  939. SSL_NOT_EXP|SSL_HIGH,
  940. SSL_HANDSHAKE_MAC_DEFAULT|TLS1_PRF,
  941. 256,
  942. 256,
  943. },
  944. /* Cipher 36 */
  945. {
  946. 0,
  947. TLS1_TXT_DH_DSS_WITH_AES_256_SHA,
  948. TLS1_CK_DH_DSS_WITH_AES_256_SHA,
  949. SSL_kDHd,
  950. SSL_aDH,
  951. SSL_AES256,
  952. SSL_SHA1,
  953. SSL_TLSV1,
  954. SSL_NOT_EXP|SSL_HIGH,
  955. SSL_HANDSHAKE_MAC_DEFAULT|TLS1_PRF,
  956. 256,
  957. 256,
  958. },
  959. /* Cipher 37 */
  960. {
  961. 0, /* not implemented (non-ephemeral DH) */
  962. TLS1_TXT_DH_RSA_WITH_AES_256_SHA,
  963. TLS1_CK_DH_RSA_WITH_AES_256_SHA,
  964. SSL_kDHr,
  965. SSL_aDH,
  966. SSL_AES256,
  967. SSL_SHA1,
  968. SSL_TLSV1,
  969. SSL_NOT_EXP|SSL_HIGH,
  970. SSL_HANDSHAKE_MAC_DEFAULT|TLS1_PRF,
  971. 256,
  972. 256,
  973. },
  974. /* Cipher 38 */
  975. {
  976. 1,
  977. TLS1_TXT_DHE_DSS_WITH_AES_256_SHA,
  978. TLS1_CK_DHE_DSS_WITH_AES_256_SHA,
  979. SSL_kEDH,
  980. SSL_aDSS,
  981. SSL_AES256,
  982. SSL_SHA1,
  983. SSL_TLSV1,
  984. SSL_NOT_EXP|SSL_HIGH,
  985. SSL_HANDSHAKE_MAC_DEFAULT|TLS1_PRF,
  986. 256,
  987. 256,
  988. },
  989. /* Cipher 39 */
  990. {
  991. 1,
  992. TLS1_TXT_DHE_RSA_WITH_AES_256_SHA,
  993. TLS1_CK_DHE_RSA_WITH_AES_256_SHA,
  994. SSL_kEDH,
  995. SSL_aRSA,
  996. SSL_AES256,
  997. SSL_SHA1,
  998. SSL_TLSV1,
  999. SSL_NOT_EXP|SSL_HIGH,
  1000. SSL_HANDSHAKE_MAC_DEFAULT|TLS1_PRF,
  1001. 256,
  1002. 256,
  1003. },
  1004. /* Cipher 3A */
  1005. {
  1006. 1,
  1007. TLS1_TXT_ADH_WITH_AES_256_SHA,
  1008. TLS1_CK_ADH_WITH_AES_256_SHA,
  1009. SSL_kEDH,
  1010. SSL_aNULL,
  1011. SSL_AES256,
  1012. SSL_SHA1,
  1013. SSL_TLSV1,
  1014. SSL_NOT_EXP|SSL_HIGH,
  1015. SSL_HANDSHAKE_MAC_DEFAULT|TLS1_PRF,
  1016. 256,
  1017. 256,
  1018. },
  1019. #ifndef OPENSSL_NO_CAMELLIA
  1020. /* Camellia ciphersuites from RFC4132 (128-bit portion) */
  1021. /* Cipher 41 */
  1022. {
  1023. 1,
  1024. TLS1_TXT_RSA_WITH_CAMELLIA_128_CBC_SHA,
  1025. TLS1_CK_RSA_WITH_CAMELLIA_128_CBC_SHA,
  1026. SSL_kRSA,
  1027. SSL_aRSA,
  1028. SSL_CAMELLIA128,
  1029. SSL_SHA1,
  1030. SSL_TLSV1,
  1031. SSL_NOT_EXP|SSL_HIGH,
  1032. SSL_HANDSHAKE_MAC_DEFAULT|TLS1_PRF,
  1033. 128,
  1034. 128,
  1035. },
  1036. /* Cipher 42 */
  1037. {
  1038. 0, /* not implemented (non-ephemeral DH) */
  1039. TLS1_TXT_DH_DSS_WITH_CAMELLIA_128_CBC_SHA,
  1040. TLS1_CK_DH_DSS_WITH_CAMELLIA_128_CBC_SHA,
  1041. SSL_kDHd,
  1042. SSL_aDH,
  1043. SSL_CAMELLIA128,
  1044. SSL_SHA1,
  1045. SSL_TLSV1,
  1046. SSL_NOT_EXP|SSL_HIGH,
  1047. SSL_HANDSHAKE_MAC_DEFAULT|TLS1_PRF,
  1048. 128,
  1049. 128,
  1050. },
  1051. /* Cipher 43 */
  1052. {
  1053. 0, /* not implemented (non-ephemeral DH) */
  1054. TLS1_TXT_DH_RSA_WITH_CAMELLIA_128_CBC_SHA,
  1055. TLS1_CK_DH_RSA_WITH_CAMELLIA_128_CBC_SHA,
  1056. SSL_kDHr,
  1057. SSL_aDH,
  1058. SSL_CAMELLIA128,
  1059. SSL_SHA1,
  1060. SSL_TLSV1,
  1061. SSL_NOT_EXP|SSL_HIGH,
  1062. SSL_HANDSHAKE_MAC_DEFAULT|TLS1_PRF,
  1063. 128,
  1064. 128,
  1065. },
  1066. /* Cipher 44 */
  1067. {
  1068. 1,
  1069. TLS1_TXT_DHE_DSS_WITH_CAMELLIA_128_CBC_SHA,
  1070. TLS1_CK_DHE_DSS_WITH_CAMELLIA_128_CBC_SHA,
  1071. SSL_kEDH,
  1072. SSL_aDSS,
  1073. SSL_CAMELLIA128,
  1074. SSL_SHA1,
  1075. SSL_TLSV1,
  1076. SSL_NOT_EXP|SSL_HIGH,
  1077. SSL_HANDSHAKE_MAC_DEFAULT|TLS1_PRF,
  1078. 128,
  1079. 128,
  1080. },
  1081. /* Cipher 45 */
  1082. {
  1083. 1,
  1084. TLS1_TXT_DHE_RSA_WITH_CAMELLIA_128_CBC_SHA,
  1085. TLS1_CK_DHE_RSA_WITH_CAMELLIA_128_CBC_SHA,
  1086. SSL_kEDH,
  1087. SSL_aRSA,
  1088. SSL_CAMELLIA128,
  1089. SSL_SHA1,
  1090. SSL_TLSV1,
  1091. SSL_NOT_EXP|SSL_HIGH,
  1092. SSL_HANDSHAKE_MAC_DEFAULT|TLS1_PRF,
  1093. 128,
  1094. 128,
  1095. },
  1096. /* Cipher 46 */
  1097. {
  1098. 1,
  1099. TLS1_TXT_ADH_WITH_CAMELLIA_128_CBC_SHA,
  1100. TLS1_CK_ADH_WITH_CAMELLIA_128_CBC_SHA,
  1101. SSL_kEDH,
  1102. SSL_aNULL,
  1103. SSL_CAMELLIA128,
  1104. SSL_SHA1,
  1105. SSL_TLSV1,
  1106. SSL_NOT_EXP|SSL_HIGH,
  1107. SSL_HANDSHAKE_MAC_DEFAULT|TLS1_PRF,
  1108. 128,
  1109. 128,
  1110. },
  1111. #endif /* OPENSSL_NO_CAMELLIA */
  1112. #if TLS1_ALLOW_EXPERIMENTAL_CIPHERSUITES
  1113. /* New TLS Export CipherSuites from expired ID */
  1114. #if 0
  1115. /* Cipher 60 */
  1116. {
  1117. 1,
  1118. TLS1_TXT_RSA_EXPORT1024_WITH_RC4_56_MD5,
  1119. TLS1_CK_RSA_EXPORT1024_WITH_RC4_56_MD5,
  1120. SSL_kRSA,
  1121. SSL_aRSA,
  1122. SSL_RC4,
  1123. SSL_MD5,
  1124. SSL_TLSV1,
  1125. SSL_EXPORT|SSL_EXP56,
  1126. SSL_HANDSHAKE_MAC_DEFAULT|TLS1_PRF,
  1127. 56,
  1128. 128,
  1129. },
  1130. /* Cipher 61 */
  1131. {
  1132. 1,
  1133. TLS1_TXT_RSA_EXPORT1024_WITH_RC2_CBC_56_MD5,
  1134. TLS1_CK_RSA_EXPORT1024_WITH_RC2_CBC_56_MD5,
  1135. SSL_kRSA,
  1136. SSL_aRSA,
  1137. SSL_RC2,
  1138. SSL_MD5,
  1139. SSL_TLSV1,
  1140. SSL_EXPORT|SSL_EXP56,
  1141. SSL_HANDSHAKE_MAC_DEFAULT|TLS1_PRF,
  1142. 56,
  1143. 128,
  1144. },
  1145. #endif
  1146. /* Cipher 62 */
  1147. {
  1148. 1,
  1149. TLS1_TXT_RSA_EXPORT1024_WITH_DES_CBC_SHA,
  1150. TLS1_CK_RSA_EXPORT1024_WITH_DES_CBC_SHA,
  1151. SSL_kRSA,
  1152. SSL_aRSA,
  1153. SSL_DES,
  1154. SSL_SHA1,
  1155. SSL_TLSV1,
  1156. SSL_EXPORT|SSL_EXP56,
  1157. SSL_HANDSHAKE_MAC_DEFAULT|TLS1_PRF,
  1158. 56,
  1159. 56,
  1160. },
  1161. /* Cipher 63 */
  1162. {
  1163. 1,
  1164. TLS1_TXT_DHE_DSS_EXPORT1024_WITH_DES_CBC_SHA,
  1165. TLS1_CK_DHE_DSS_EXPORT1024_WITH_DES_CBC_SHA,
  1166. SSL_kEDH,
  1167. SSL_aDSS,
  1168. SSL_DES,
  1169. SSL_SHA1,
  1170. SSL_TLSV1,
  1171. SSL_EXPORT|SSL_EXP56,
  1172. SSL_HANDSHAKE_MAC_DEFAULT|TLS1_PRF,
  1173. 56,
  1174. 56,
  1175. },
  1176. /* Cipher 64 */
  1177. {
  1178. 1,
  1179. TLS1_TXT_RSA_EXPORT1024_WITH_RC4_56_SHA,
  1180. TLS1_CK_RSA_EXPORT1024_WITH_RC4_56_SHA,
  1181. SSL_kRSA,
  1182. SSL_aRSA,
  1183. SSL_RC4,
  1184. SSL_SHA1,
  1185. SSL_TLSV1,
  1186. SSL_EXPORT|SSL_EXP56,
  1187. SSL_HANDSHAKE_MAC_DEFAULT|TLS1_PRF,
  1188. 56,
  1189. 128,
  1190. },
  1191. /* Cipher 65 */
  1192. {
  1193. 1,
  1194. TLS1_TXT_DHE_DSS_EXPORT1024_WITH_RC4_56_SHA,
  1195. TLS1_CK_DHE_DSS_EXPORT1024_WITH_RC4_56_SHA,
  1196. SSL_kEDH,
  1197. SSL_aDSS,
  1198. SSL_RC4,
  1199. SSL_SHA1,
  1200. SSL_TLSV1,
  1201. SSL_EXPORT|SSL_EXP56,
  1202. SSL_HANDSHAKE_MAC_DEFAULT|TLS1_PRF,
  1203. 56,
  1204. 128,
  1205. },
  1206. /* Cipher 66 */
  1207. {
  1208. 1,
  1209. TLS1_TXT_DHE_DSS_WITH_RC4_128_SHA,
  1210. TLS1_CK_DHE_DSS_WITH_RC4_128_SHA,
  1211. SSL_kEDH,
  1212. SSL_aDSS,
  1213. SSL_RC4,
  1214. SSL_SHA1,
  1215. SSL_TLSV1,
  1216. SSL_NOT_EXP|SSL_MEDIUM,
  1217. SSL_HANDSHAKE_MAC_DEFAULT|TLS1_PRF,
  1218. 128,
  1219. 128,
  1220. },
  1221. #endif
  1222. {
  1223. 1,
  1224. "GOST94-GOST89-GOST89",
  1225. 0x3000080,
  1226. SSL_kGOST,
  1227. SSL_aGOST94,
  1228. SSL_eGOST2814789CNT,
  1229. SSL_GOST89MAC,
  1230. SSL_TLSV1,
  1231. SSL_NOT_EXP|SSL_HIGH,
  1232. SSL_HANDSHAKE_MAC_GOST94|TLS1_PRF_GOST94|TLS1_STREAM_MAC,
  1233. 256,
  1234. 256
  1235. },
  1236. {
  1237. 1,
  1238. "GOST2001-GOST89-GOST89",
  1239. 0x3000081,
  1240. SSL_kGOST,
  1241. SSL_aGOST01,
  1242. SSL_eGOST2814789CNT,
  1243. SSL_GOST89MAC,
  1244. SSL_TLSV1,
  1245. SSL_NOT_EXP|SSL_HIGH,
  1246. SSL_HANDSHAKE_MAC_GOST94|TLS1_PRF_GOST94|TLS1_STREAM_MAC,
  1247. 256,
  1248. 256
  1249. },
  1250. {
  1251. 1,
  1252. "GOST94-NULL-GOST94",
  1253. 0x3000082,
  1254. SSL_kGOST,
  1255. SSL_aGOST94,
  1256. SSL_eNULL,
  1257. SSL_GOST94,
  1258. SSL_TLSV1,
  1259. SSL_NOT_EXP|SSL_STRONG_NONE,
  1260. SSL_HANDSHAKE_MAC_GOST94|TLS1_PRF_GOST94,
  1261. 0,
  1262. 0
  1263. },
  1264. {
  1265. 1,
  1266. "GOST2001-NULL-GOST94",
  1267. 0x3000083,
  1268. SSL_kGOST,
  1269. SSL_aGOST01,
  1270. SSL_eNULL,
  1271. SSL_GOST94,
  1272. SSL_TLSV1,
  1273. SSL_NOT_EXP|SSL_STRONG_NONE,
  1274. SSL_HANDSHAKE_MAC_GOST94|TLS1_PRF_GOST94,
  1275. 0,
  1276. 0
  1277. },
  1278. #ifndef OPENSSL_NO_CAMELLIA
  1279. /* Camellia ciphersuites from RFC4132 (256-bit portion) */
  1280. /* Cipher 84 */
  1281. {
  1282. 1,
  1283. TLS1_TXT_RSA_WITH_CAMELLIA_256_CBC_SHA,
  1284. TLS1_CK_RSA_WITH_CAMELLIA_256_CBC_SHA,
  1285. SSL_kRSA,
  1286. SSL_aRSA,
  1287. SSL_CAMELLIA256,
  1288. SSL_SHA1,
  1289. SSL_TLSV1,
  1290. SSL_NOT_EXP|SSL_HIGH,
  1291. SSL_HANDSHAKE_MAC_DEFAULT|TLS1_PRF,
  1292. 256,
  1293. 256,
  1294. },
  1295. /* Cipher 85 */
  1296. {
  1297. 0, /* not implemented (non-ephemeral DH) */
  1298. TLS1_TXT_DH_DSS_WITH_CAMELLIA_256_CBC_SHA,
  1299. TLS1_CK_DH_DSS_WITH_CAMELLIA_256_CBC_SHA,
  1300. SSL_kDHd,
  1301. SSL_aDH,
  1302. SSL_CAMELLIA256,
  1303. SSL_SHA1,
  1304. SSL_TLSV1,
  1305. SSL_NOT_EXP|SSL_HIGH,
  1306. SSL_HANDSHAKE_MAC_DEFAULT|TLS1_PRF,
  1307. 256,
  1308. 256,
  1309. },
  1310. /* Cipher 86 */
  1311. {
  1312. 0, /* not implemented (non-ephemeral DH) */
  1313. TLS1_TXT_DH_RSA_WITH_CAMELLIA_256_CBC_SHA,
  1314. TLS1_CK_DH_RSA_WITH_CAMELLIA_256_CBC_SHA,
  1315. SSL_kDHr,
  1316. SSL_aDH,
  1317. SSL_CAMELLIA256,
  1318. SSL_SHA1,
  1319. SSL_TLSV1,
  1320. SSL_NOT_EXP|SSL_HIGH,
  1321. SSL_HANDSHAKE_MAC_DEFAULT|TLS1_PRF,
  1322. 256,
  1323. 256,
  1324. },
  1325. /* Cipher 87 */
  1326. {
  1327. 1,
  1328. TLS1_TXT_DHE_DSS_WITH_CAMELLIA_256_CBC_SHA,
  1329. TLS1_CK_DHE_DSS_WITH_CAMELLIA_256_CBC_SHA,
  1330. SSL_kEDH,
  1331. SSL_aDSS,
  1332. SSL_CAMELLIA256,
  1333. SSL_SHA1,
  1334. SSL_TLSV1,
  1335. SSL_NOT_EXP|SSL_HIGH,
  1336. SSL_HANDSHAKE_MAC_DEFAULT|TLS1_PRF,
  1337. 256,
  1338. 256,
  1339. },
  1340. /* Cipher 88 */
  1341. {
  1342. 1,
  1343. TLS1_TXT_DHE_RSA_WITH_CAMELLIA_256_CBC_SHA,
  1344. TLS1_CK_DHE_RSA_WITH_CAMELLIA_256_CBC_SHA,
  1345. SSL_kEDH,
  1346. SSL_aRSA,
  1347. SSL_CAMELLIA256,
  1348. SSL_SHA1,
  1349. SSL_TLSV1,
  1350. SSL_NOT_EXP|SSL_HIGH,
  1351. SSL_HANDSHAKE_MAC_DEFAULT|TLS1_PRF,
  1352. 256,
  1353. 256,
  1354. },
  1355. /* Cipher 89 */
  1356. {
  1357. 1,
  1358. TLS1_TXT_ADH_WITH_CAMELLIA_256_CBC_SHA,
  1359. TLS1_CK_ADH_WITH_CAMELLIA_256_CBC_SHA,
  1360. SSL_kEDH,
  1361. SSL_aNULL,
  1362. SSL_CAMELLIA256,
  1363. SSL_SHA1,
  1364. SSL_TLSV1,
  1365. SSL_NOT_EXP|SSL_HIGH,
  1366. SSL_HANDSHAKE_MAC_DEFAULT|TLS1_PRF,
  1367. 256,
  1368. 256,
  1369. },
  1370. #endif /* OPENSSL_NO_CAMELLIA */
  1371. #ifndef OPENSSL_NO_PSK
  1372. /* Cipher 8A */
  1373. {
  1374. 1,
  1375. TLS1_TXT_PSK_WITH_RC4_128_SHA,
  1376. TLS1_CK_PSK_WITH_RC4_128_SHA,
  1377. SSL_kPSK,
  1378. SSL_aPSK,
  1379. SSL_RC4,
  1380. SSL_SHA1,
  1381. SSL_TLSV1,
  1382. SSL_NOT_EXP|SSL_MEDIUM,
  1383. SSL_HANDSHAKE_MAC_DEFAULT|TLS1_PRF,
  1384. 128,
  1385. 128,
  1386. },
  1387. /* Cipher 8B */
  1388. {
  1389. 1,
  1390. TLS1_TXT_PSK_WITH_3DES_EDE_CBC_SHA,
  1391. TLS1_CK_PSK_WITH_3DES_EDE_CBC_SHA,
  1392. SSL_kPSK,
  1393. SSL_aPSK,
  1394. SSL_3DES,
  1395. SSL_SHA1,
  1396. SSL_TLSV1,
  1397. SSL_NOT_EXP|SSL_HIGH,
  1398. SSL_HANDSHAKE_MAC_DEFAULT|TLS1_PRF,
  1399. 168,
  1400. 168,
  1401. },
  1402. /* Cipher 8C */
  1403. {
  1404. 1,
  1405. TLS1_TXT_PSK_WITH_AES_128_CBC_SHA,
  1406. TLS1_CK_PSK_WITH_AES_128_CBC_SHA,
  1407. SSL_kPSK,
  1408. SSL_aPSK,
  1409. SSL_AES128,
  1410. SSL_SHA1,
  1411. SSL_TLSV1,
  1412. SSL_NOT_EXP|SSL_HIGH,
  1413. SSL_HANDSHAKE_MAC_DEFAULT|TLS1_PRF,
  1414. 128,
  1415. 128,
  1416. },
  1417. /* Cipher 8D */
  1418. {
  1419. 1,
  1420. TLS1_TXT_PSK_WITH_AES_256_CBC_SHA,
  1421. TLS1_CK_PSK_WITH_AES_256_CBC_SHA,
  1422. SSL_kPSK,
  1423. SSL_aPSK,
  1424. SSL_AES256,
  1425. SSL_SHA1,
  1426. SSL_TLSV1,
  1427. SSL_NOT_EXP|SSL_HIGH,
  1428. SSL_HANDSHAKE_MAC_DEFAULT|TLS1_PRF,
  1429. 256,
  1430. 256,
  1431. },
  1432. #endif /* OPENSSL_NO_PSK */
  1433. #ifndef OPENSSL_NO_SEED
  1434. /* SEED ciphersuites from RFC4162 */
  1435. /* Cipher 96 */
  1436. {
  1437. 1,
  1438. TLS1_TXT_RSA_WITH_SEED_SHA,
  1439. TLS1_CK_RSA_WITH_SEED_SHA,
  1440. SSL_kRSA,
  1441. SSL_aRSA,
  1442. SSL_SEED,
  1443. SSL_SHA1,
  1444. SSL_TLSV1,
  1445. SSL_NOT_EXP|SSL_MEDIUM,
  1446. SSL_HANDSHAKE_MAC_DEFAULT|TLS1_PRF,
  1447. 128,
  1448. 128,
  1449. },
  1450. /* Cipher 97 */
  1451. {
  1452. 0, /* not implemented (non-ephemeral DH) */
  1453. TLS1_TXT_DH_DSS_WITH_SEED_SHA,
  1454. TLS1_CK_DH_DSS_WITH_SEED_SHA,
  1455. SSL_kDHd,
  1456. SSL_aDH,
  1457. SSL_SEED,
  1458. SSL_SHA1,
  1459. SSL_TLSV1,
  1460. SSL_NOT_EXP|SSL_MEDIUM,
  1461. SSL_HANDSHAKE_MAC_DEFAULT|TLS1_PRF,
  1462. 128,
  1463. 128,
  1464. },
  1465. /* Cipher 98 */
  1466. {
  1467. 0, /* not implemented (non-ephemeral DH) */
  1468. TLS1_TXT_DH_RSA_WITH_SEED_SHA,
  1469. TLS1_CK_DH_RSA_WITH_SEED_SHA,
  1470. SSL_kDHr,
  1471. SSL_aDH,
  1472. SSL_SEED,
  1473. SSL_SHA1,
  1474. SSL_TLSV1,
  1475. SSL_NOT_EXP|SSL_MEDIUM,
  1476. SSL_HANDSHAKE_MAC_DEFAULT|TLS1_PRF,
  1477. 128,
  1478. 128,
  1479. },
  1480. /* Cipher 99 */
  1481. {
  1482. 1,
  1483. TLS1_TXT_DHE_DSS_WITH_SEED_SHA,
  1484. TLS1_CK_DHE_DSS_WITH_SEED_SHA,
  1485. SSL_kEDH,
  1486. SSL_aDSS,
  1487. SSL_SEED,
  1488. SSL_SHA1,
  1489. SSL_TLSV1,
  1490. SSL_NOT_EXP|SSL_MEDIUM,
  1491. SSL_HANDSHAKE_MAC_DEFAULT|TLS1_PRF,
  1492. 128,
  1493. 128,
  1494. },
  1495. /* Cipher 9A */
  1496. {
  1497. 1,
  1498. TLS1_TXT_DHE_RSA_WITH_SEED_SHA,
  1499. TLS1_CK_DHE_RSA_WITH_SEED_SHA,
  1500. SSL_kEDH,
  1501. SSL_aRSA,
  1502. SSL_SEED,
  1503. SSL_SHA1,
  1504. SSL_TLSV1,
  1505. SSL_NOT_EXP|SSL_MEDIUM,
  1506. SSL_HANDSHAKE_MAC_DEFAULT|TLS1_PRF,
  1507. 128,
  1508. 128,
  1509. },
  1510. /* Cipher 9B */
  1511. {
  1512. 1,
  1513. TLS1_TXT_ADH_WITH_SEED_SHA,
  1514. TLS1_CK_ADH_WITH_SEED_SHA,
  1515. SSL_kEDH,
  1516. SSL_aNULL,
  1517. SSL_SEED,
  1518. SSL_SHA1,
  1519. SSL_TLSV1,
  1520. SSL_NOT_EXP|SSL_MEDIUM,
  1521. SSL_HANDSHAKE_MAC_DEFAULT|TLS1_PRF,
  1522. 128,
  1523. 128,
  1524. },
  1525. #endif /* OPENSSL_NO_SEED */
  1526. #ifndef OPENSSL_NO_ECDH
  1527. /* Cipher C001 */
  1528. {
  1529. 1,
  1530. TLS1_TXT_ECDH_ECDSA_WITH_NULL_SHA,
  1531. TLS1_CK_ECDH_ECDSA_WITH_NULL_SHA,
  1532. SSL_kECDHe,
  1533. SSL_aECDH,
  1534. SSL_eNULL,
  1535. SSL_SHA1,
  1536. SSL_TLSV1,
  1537. SSL_NOT_EXP|SSL_STRONG_NONE,
  1538. SSL_HANDSHAKE_MAC_DEFAULT|TLS1_PRF,
  1539. 0,
  1540. 0,
  1541. },
  1542. /* Cipher C002 */
  1543. {
  1544. 1,
  1545. TLS1_TXT_ECDH_ECDSA_WITH_RC4_128_SHA,
  1546. TLS1_CK_ECDH_ECDSA_WITH_RC4_128_SHA,
  1547. SSL_kECDHe,
  1548. SSL_aECDH,
  1549. SSL_RC4,
  1550. SSL_SHA1,
  1551. SSL_TLSV1,
  1552. SSL_NOT_EXP|SSL_MEDIUM,
  1553. SSL_HANDSHAKE_MAC_DEFAULT|TLS1_PRF,
  1554. 128,
  1555. 128,
  1556. },
  1557. /* Cipher C003 */
  1558. {
  1559. 1,
  1560. TLS1_TXT_ECDH_ECDSA_WITH_DES_192_CBC3_SHA,
  1561. TLS1_CK_ECDH_ECDSA_WITH_DES_192_CBC3_SHA,
  1562. SSL_kECDHe,
  1563. SSL_aECDH,
  1564. SSL_3DES,
  1565. SSL_SHA1,
  1566. SSL_TLSV1,
  1567. SSL_NOT_EXP|SSL_HIGH,
  1568. SSL_HANDSHAKE_MAC_DEFAULT|TLS1_PRF,
  1569. 168,
  1570. 168,
  1571. },
  1572. /* Cipher C004 */
  1573. {
  1574. 1,
  1575. TLS1_TXT_ECDH_ECDSA_WITH_AES_128_CBC_SHA,
  1576. TLS1_CK_ECDH_ECDSA_WITH_AES_128_CBC_SHA,
  1577. SSL_kECDHe,
  1578. SSL_aECDH,
  1579. SSL_AES128,
  1580. SSL_SHA1,
  1581. SSL_TLSV1,
  1582. SSL_NOT_EXP|SSL_HIGH,
  1583. SSL_HANDSHAKE_MAC_DEFAULT|TLS1_PRF,
  1584. 128,
  1585. 128,
  1586. },
  1587. /* Cipher C005 */
  1588. {
  1589. 1,
  1590. TLS1_TXT_ECDH_ECDSA_WITH_AES_256_CBC_SHA,
  1591. TLS1_CK_ECDH_ECDSA_WITH_AES_256_CBC_SHA,
  1592. SSL_kECDHe,
  1593. SSL_aECDH,
  1594. SSL_AES256,
  1595. SSL_SHA1,
  1596. SSL_TLSV1,
  1597. SSL_NOT_EXP|SSL_HIGH,
  1598. SSL_HANDSHAKE_MAC_DEFAULT|TLS1_PRF,
  1599. 256,
  1600. 256,
  1601. },
  1602. /* Cipher C006 */
  1603. {
  1604. 1,
  1605. TLS1_TXT_ECDHE_ECDSA_WITH_NULL_SHA,
  1606. TLS1_CK_ECDHE_ECDSA_WITH_NULL_SHA,
  1607. SSL_kEECDH,
  1608. SSL_aECDSA,
  1609. SSL_eNULL,
  1610. SSL_SHA1,
  1611. SSL_TLSV1,
  1612. SSL_NOT_EXP|SSL_STRONG_NONE,
  1613. SSL_HANDSHAKE_MAC_DEFAULT|TLS1_PRF,
  1614. 0,
  1615. 0,
  1616. },
  1617. /* Cipher C007 */
  1618. {
  1619. 1,
  1620. TLS1_TXT_ECDHE_ECDSA_WITH_RC4_128_SHA,
  1621. TLS1_CK_ECDHE_ECDSA_WITH_RC4_128_SHA,
  1622. SSL_kEECDH,
  1623. SSL_aECDSA,
  1624. SSL_RC4,
  1625. SSL_SHA1,
  1626. SSL_TLSV1,
  1627. SSL_NOT_EXP|SSL_MEDIUM,
  1628. SSL_HANDSHAKE_MAC_DEFAULT|TLS1_PRF,
  1629. 128,
  1630. 128,
  1631. },
  1632. /* Cipher C008 */
  1633. {
  1634. 1,
  1635. TLS1_TXT_ECDHE_ECDSA_WITH_DES_192_CBC3_SHA,
  1636. TLS1_CK_ECDHE_ECDSA_WITH_DES_192_CBC3_SHA,
  1637. SSL_kEECDH,
  1638. SSL_aECDSA,
  1639. SSL_3DES,
  1640. SSL_SHA1,
  1641. SSL_TLSV1,
  1642. SSL_NOT_EXP|SSL_HIGH,
  1643. SSL_HANDSHAKE_MAC_DEFAULT|TLS1_PRF,
  1644. 168,
  1645. 168,
  1646. },
  1647. /* Cipher C009 */
  1648. {
  1649. 1,
  1650. TLS1_TXT_ECDHE_ECDSA_WITH_AES_128_CBC_SHA,
  1651. TLS1_CK_ECDHE_ECDSA_WITH_AES_128_CBC_SHA,
  1652. SSL_kEECDH,
  1653. SSL_aECDSA,
  1654. SSL_AES128,
  1655. SSL_SHA1,
  1656. SSL_TLSV1,
  1657. SSL_NOT_EXP|SSL_HIGH,
  1658. SSL_HANDSHAKE_MAC_DEFAULT|TLS1_PRF,
  1659. 128,
  1660. 128,
  1661. },
  1662. /* Cipher C00A */
  1663. {
  1664. 1,
  1665. TLS1_TXT_ECDHE_ECDSA_WITH_AES_256_CBC_SHA,
  1666. TLS1_CK_ECDHE_ECDSA_WITH_AES_256_CBC_SHA,
  1667. SSL_kEECDH,
  1668. SSL_aECDSA,
  1669. SSL_AES256,
  1670. SSL_SHA1,
  1671. SSL_TLSV1,
  1672. SSL_NOT_EXP|SSL_HIGH,
  1673. SSL_HANDSHAKE_MAC_DEFAULT|TLS1_PRF,
  1674. 256,
  1675. 256,
  1676. },
  1677. /* Cipher C00B */
  1678. {
  1679. 1,
  1680. TLS1_TXT_ECDH_RSA_WITH_NULL_SHA,
  1681. TLS1_CK_ECDH_RSA_WITH_NULL_SHA,
  1682. SSL_kECDHr,
  1683. SSL_aECDH,
  1684. SSL_eNULL,
  1685. SSL_SHA1,
  1686. SSL_TLSV1,
  1687. SSL_NOT_EXP|SSL_STRONG_NONE,
  1688. SSL_HANDSHAKE_MAC_DEFAULT|TLS1_PRF,
  1689. 0,
  1690. 0,
  1691. },
  1692. /* Cipher C00C */
  1693. {
  1694. 1,
  1695. TLS1_TXT_ECDH_RSA_WITH_RC4_128_SHA,
  1696. TLS1_CK_ECDH_RSA_WITH_RC4_128_SHA,
  1697. SSL_kECDHr,
  1698. SSL_aECDH,
  1699. SSL_RC4,
  1700. SSL_SHA1,
  1701. SSL_TLSV1,
  1702. SSL_NOT_EXP|SSL_MEDIUM,
  1703. SSL_HANDSHAKE_MAC_DEFAULT|TLS1_PRF,
  1704. 128,
  1705. 128,
  1706. },
  1707. /* Cipher C00D */
  1708. {
  1709. 1,
  1710. TLS1_TXT_ECDH_RSA_WITH_DES_192_CBC3_SHA,
  1711. TLS1_CK_ECDH_RSA_WITH_DES_192_CBC3_SHA,
  1712. SSL_kECDHr,
  1713. SSL_aECDH,
  1714. SSL_3DES,
  1715. SSL_SHA1,
  1716. SSL_TLSV1,
  1717. SSL_NOT_EXP|SSL_HIGH,
  1718. SSL_HANDSHAKE_MAC_DEFAULT|TLS1_PRF,
  1719. 168,
  1720. 168,
  1721. },
  1722. /* Cipher C00E */
  1723. {
  1724. 1,
  1725. TLS1_TXT_ECDH_RSA_WITH_AES_128_CBC_SHA,
  1726. TLS1_CK_ECDH_RSA_WITH_AES_128_CBC_SHA,
  1727. SSL_kECDHr,
  1728. SSL_aECDH,
  1729. SSL_AES128,
  1730. SSL_SHA1,
  1731. SSL_TLSV1,
  1732. SSL_NOT_EXP|SSL_HIGH,
  1733. SSL_HANDSHAKE_MAC_DEFAULT|TLS1_PRF,
  1734. 128,
  1735. 128,
  1736. },
  1737. /* Cipher C00F */
  1738. {
  1739. 1,
  1740. TLS1_TXT_ECDH_RSA_WITH_AES_256_CBC_SHA,
  1741. TLS1_CK_ECDH_RSA_WITH_AES_256_CBC_SHA,
  1742. SSL_kECDHr,
  1743. SSL_aECDH,
  1744. SSL_AES256,
  1745. SSL_SHA1,
  1746. SSL_TLSV1,
  1747. SSL_NOT_EXP|SSL_HIGH,
  1748. SSL_HANDSHAKE_MAC_DEFAULT|TLS1_PRF,
  1749. 256,
  1750. 256,
  1751. },
  1752. /* Cipher C010 */
  1753. {
  1754. 1,
  1755. TLS1_TXT_ECDHE_RSA_WITH_NULL_SHA,
  1756. TLS1_CK_ECDHE_RSA_WITH_NULL_SHA,
  1757. SSL_kEECDH,
  1758. SSL_aRSA,
  1759. SSL_eNULL,
  1760. SSL_SHA1,
  1761. SSL_TLSV1,
  1762. SSL_NOT_EXP|SSL_STRONG_NONE,
  1763. SSL_HANDSHAKE_MAC_DEFAULT|TLS1_PRF,
  1764. 0,
  1765. 0,
  1766. },
  1767. /* Cipher C011 */
  1768. {
  1769. 1,
  1770. TLS1_TXT_ECDHE_RSA_WITH_RC4_128_SHA,
  1771. TLS1_CK_ECDHE_RSA_WITH_RC4_128_SHA,
  1772. SSL_kEECDH,
  1773. SSL_aRSA,
  1774. SSL_RC4,
  1775. SSL_SHA1,
  1776. SSL_TLSV1,
  1777. SSL_NOT_EXP|SSL_MEDIUM,
  1778. SSL_HANDSHAKE_MAC_DEFAULT|TLS1_PRF,
  1779. 128,
  1780. 128,
  1781. },
  1782. /* Cipher C012 */
  1783. {
  1784. 1,
  1785. TLS1_TXT_ECDHE_RSA_WITH_DES_192_CBC3_SHA,
  1786. TLS1_CK_ECDHE_RSA_WITH_DES_192_CBC3_SHA,
  1787. SSL_kEECDH,
  1788. SSL_aRSA,
  1789. SSL_3DES,
  1790. SSL_SHA1,
  1791. SSL_TLSV1,
  1792. SSL_NOT_EXP|SSL_HIGH,
  1793. SSL_HANDSHAKE_MAC_DEFAULT|TLS1_PRF,
  1794. 168,
  1795. 168,
  1796. },
  1797. /* Cipher C013 */
  1798. {
  1799. 1,
  1800. TLS1_TXT_ECDHE_RSA_WITH_AES_128_CBC_SHA,
  1801. TLS1_CK_ECDHE_RSA_WITH_AES_128_CBC_SHA,
  1802. SSL_kEECDH,
  1803. SSL_aRSA,
  1804. SSL_AES128,
  1805. SSL_SHA1,
  1806. SSL_TLSV1,
  1807. SSL_NOT_EXP|SSL_HIGH,
  1808. SSL_HANDSHAKE_MAC_DEFAULT|TLS1_PRF,
  1809. 128,
  1810. 128,
  1811. },
  1812. /* Cipher C014 */
  1813. {
  1814. 1,
  1815. TLS1_TXT_ECDHE_RSA_WITH_AES_256_CBC_SHA,
  1816. TLS1_CK_ECDHE_RSA_WITH_AES_256_CBC_SHA,
  1817. SSL_kEECDH,
  1818. SSL_aRSA,
  1819. SSL_AES256,
  1820. SSL_SHA1,
  1821. SSL_TLSV1,
  1822. SSL_NOT_EXP|SSL_HIGH,
  1823. SSL_HANDSHAKE_MAC_DEFAULT|TLS1_PRF,
  1824. 256,
  1825. 256,
  1826. },
  1827. /* Cipher C015 */
  1828. {
  1829. 1,
  1830. TLS1_TXT_ECDH_anon_WITH_NULL_SHA,
  1831. TLS1_CK_ECDH_anon_WITH_NULL_SHA,
  1832. SSL_kEECDH,
  1833. SSL_aNULL,
  1834. SSL_eNULL,
  1835. SSL_SHA1,
  1836. SSL_TLSV1,
  1837. SSL_NOT_EXP|SSL_STRONG_NONE,
  1838. SSL_HANDSHAKE_MAC_DEFAULT|TLS1_PRF,
  1839. 0,
  1840. 0,
  1841. },
  1842. /* Cipher C016 */
  1843. {
  1844. 1,
  1845. TLS1_TXT_ECDH_anon_WITH_RC4_128_SHA,
  1846. TLS1_CK_ECDH_anon_WITH_RC4_128_SHA,
  1847. SSL_kEECDH,
  1848. SSL_aNULL,
  1849. SSL_RC4,
  1850. SSL_SHA1,
  1851. SSL_TLSV1,
  1852. SSL_NOT_EXP|SSL_MEDIUM,
  1853. SSL_HANDSHAKE_MAC_DEFAULT|TLS1_PRF,
  1854. 128,
  1855. 128,
  1856. },
  1857. /* Cipher C017 */
  1858. {
  1859. 1,
  1860. TLS1_TXT_ECDH_anon_WITH_DES_192_CBC3_SHA,
  1861. TLS1_CK_ECDH_anon_WITH_DES_192_CBC3_SHA,
  1862. SSL_kEECDH,
  1863. SSL_aNULL,
  1864. SSL_3DES,
  1865. SSL_SHA1,
  1866. SSL_TLSV1,
  1867. SSL_NOT_EXP|SSL_HIGH,
  1868. SSL_HANDSHAKE_MAC_DEFAULT|TLS1_PRF,
  1869. 168,
  1870. 168,
  1871. },
  1872. /* Cipher C018 */
  1873. {
  1874. 1,
  1875. TLS1_TXT_ECDH_anon_WITH_AES_128_CBC_SHA,
  1876. TLS1_CK_ECDH_anon_WITH_AES_128_CBC_SHA,
  1877. SSL_kEECDH,
  1878. SSL_aNULL,
  1879. SSL_AES128,
  1880. SSL_SHA1,
  1881. SSL_TLSV1,
  1882. SSL_NOT_EXP|SSL_HIGH,
  1883. SSL_HANDSHAKE_MAC_DEFAULT|TLS1_PRF,
  1884. 128,
  1885. 128,
  1886. },
  1887. /* Cipher C019 */
  1888. {
  1889. 1,
  1890. TLS1_TXT_ECDH_anon_WITH_AES_256_CBC_SHA,
  1891. TLS1_CK_ECDH_anon_WITH_AES_256_CBC_SHA,
  1892. SSL_kEECDH,
  1893. SSL_aNULL,
  1894. SSL_AES256,
  1895. SSL_SHA1,
  1896. SSL_TLSV1,
  1897. SSL_NOT_EXP|SSL_HIGH,
  1898. SSL_HANDSHAKE_MAC_DEFAULT|TLS1_PRF,
  1899. 256,
  1900. 256,
  1901. },
  1902. #endif /* OPENSSL_NO_ECDH */
  1903. #ifdef TEMP_GOST_TLS
  1904. /* Cipher FF00 */
  1905. {
  1906. 1,
  1907. "GOST-MD5",
  1908. 0x0300ff00,
  1909. SSL_kRSA,
  1910. SSL_aRSA,
  1911. SSL_eGOST2814789CNT,
  1912. SSL_MD5,
  1913. SSL_TLSV1,
  1914. SSL_NOT_EXP|SSL_HIGH,
  1915. SSL_HANDSHAKE_MAC_DEFAULT|TLS1_PRF,
  1916. 256,
  1917. 256,
  1918. },
  1919. {
  1920. 1,
  1921. "GOST-GOST94",
  1922. 0x0300ff01,
  1923. SSL_kRSA,
  1924. SSL_aRSA,
  1925. SSL_eGOST2814789CNT,
  1926. SSL_GOST94,
  1927. SSL_TLSV1,
  1928. SSL_NOT_EXP|SSL_HIGH,
  1929. SSL_HANDSHAKE_MAC_DEFAULT|TLS1_PRF,
  1930. 256,
  1931. 256
  1932. },
  1933. {
  1934. 1,
  1935. "GOST-GOST89MAC",
  1936. 0x0300ff02,
  1937. SSL_kRSA,
  1938. SSL_aRSA,
  1939. SSL_eGOST2814789CNT,
  1940. SSL_GOST89MAC,
  1941. SSL_TLSV1,
  1942. SSL_NOT_EXP|SSL_HIGH,
  1943. SSL_HANDSHAKE_MAC_DEFAULT|TLS1_PRF,
  1944. 256,
  1945. 256
  1946. },
  1947. {
  1948. 1,
  1949. "GOST-GOST89STREAM",
  1950. 0x0300ff03,
  1951. SSL_kRSA,
  1952. SSL_aRSA,
  1953. SSL_eGOST2814789CNT,
  1954. SSL_GOST89MAC,
  1955. SSL_TLSV1,
  1956. SSL_NOT_EXP|SSL_HIGH,
  1957. SSL_HANDSHAKE_MAC_DEFAULT|TLS1_PRF|TLS1_STREAM_MAC,
  1958. 256,
  1959. 256
  1960. },
  1961. #endif
  1962. /* end of list */
  1963. };
  1964. SSL3_ENC_METHOD SSLv3_enc_data={
  1965. ssl3_enc,
  1966. ssl3_mac,
  1967. ssl3_setup_key_block,
  1968. ssl3_generate_master_secret,
  1969. ssl3_change_cipher_state,
  1970. ssl3_final_finish_mac,
  1971. MD5_DIGEST_LENGTH+SHA_DIGEST_LENGTH,
  1972. ssl3_cert_verify_mac,
  1973. SSL3_MD_CLIENT_FINISHED_CONST,4,
  1974. SSL3_MD_SERVER_FINISHED_CONST,4,
  1975. ssl3_alert_code,
  1976. };
  1977. long ssl3_default_timeout(void)
  1978. {
  1979. /* 2 hours, the 24 hours mentioned in the SSLv3 spec
  1980. * is way too long for http, the cache would over fill */
  1981. return(60*60*2);
  1982. }
  1983. int ssl3_num_ciphers(void)
  1984. {
  1985. return(SSL3_NUM_CIPHERS);
  1986. }
  1987. SSL_CIPHER *ssl3_get_cipher(unsigned int u)
  1988. {
  1989. if (u < SSL3_NUM_CIPHERS)
  1990. return(&(ssl3_ciphers[SSL3_NUM_CIPHERS-1-u]));
  1991. else
  1992. return(NULL);
  1993. }
  1994. int ssl3_pending(const SSL *s)
  1995. {
  1996. if (s->rstate == SSL_ST_READ_BODY)
  1997. return 0;
  1998. return (s->s3->rrec.type == SSL3_RT_APPLICATION_DATA) ? s->s3->rrec.length : 0;
  1999. }
  2000. int ssl3_new(SSL *s)
  2001. {
  2002. SSL3_STATE *s3;
  2003. if ((s3=OPENSSL_malloc(sizeof *s3)) == NULL) goto err;
  2004. memset(s3,0,sizeof *s3);
  2005. memset(s3->rrec.seq_num,0,sizeof(s3->rrec.seq_num));
  2006. memset(s3->wrec.seq_num,0,sizeof(s3->wrec.seq_num));
  2007. s->s3=s3;
  2008. s->method->ssl_clear(s);
  2009. return(1);
  2010. err:
  2011. return(0);
  2012. }
  2013. void ssl3_free(SSL *s)
  2014. {
  2015. if(s == NULL)
  2016. return;
  2017. #ifdef TLSEXT_TYPE_opaque_prf_input
  2018. if (s->s3->client_opaque_prf_input != NULL)
  2019. OPENSSL_free(s->s3->client_opaque_prf_input);
  2020. if (s->s3->server_opaque_prf_input != NULL)
  2021. OPENSSL_free(s->s3->server_opaque_prf_input);
  2022. #endif
  2023. ssl3_cleanup_key_block(s);
  2024. if (s->s3->rbuf.buf != NULL)
  2025. OPENSSL_free(s->s3->rbuf.buf);
  2026. if (s->s3->wbuf.buf != NULL)
  2027. OPENSSL_free(s->s3->wbuf.buf);
  2028. if (s->s3->rrec.comp != NULL)
  2029. OPENSSL_free(s->s3->rrec.comp);
  2030. #ifndef OPENSSL_NO_DH
  2031. if (s->s3->tmp.dh != NULL)
  2032. DH_free(s->s3->tmp.dh);
  2033. #endif
  2034. #ifndef OPENSSL_NO_ECDH
  2035. if (s->s3->tmp.ecdh != NULL)
  2036. EC_KEY_free(s->s3->tmp.ecdh);
  2037. #endif
  2038. if (s->s3->tmp.ca_names != NULL)
  2039. sk_X509_NAME_pop_free(s->s3->tmp.ca_names,X509_NAME_free);
  2040. if (s->s3->handshake_buffer) {
  2041. BIO_free(s->s3->handshake_buffer);
  2042. }
  2043. if (s->s3->handshake_dgst) ssl3_free_digest_list(s);
  2044. OPENSSL_cleanse(s->s3,sizeof *s->s3);
  2045. OPENSSL_free(s->s3);
  2046. s->s3=NULL;
  2047. }
  2048. void ssl3_clear(SSL *s)
  2049. {
  2050. unsigned char *rp,*wp;
  2051. size_t rlen, wlen;
  2052. #ifdef TLSEXT_TYPE_opaque_prf_input
  2053. if (s->s3->client_opaque_prf_input != NULL)
  2054. OPENSSL_free(s->s3->client_opaque_prf_input);
  2055. s->s3->client_opaque_prf_input = NULL;
  2056. if (s->s3->server_opaque_prf_input != NULL)
  2057. OPENSSL_free(s->s3->server_opaque_prf_input);
  2058. s->s3->server_opaque_prf_input = NULL;
  2059. #endif
  2060. ssl3_cleanup_key_block(s);
  2061. if (s->s3->tmp.ca_names != NULL)
  2062. sk_X509_NAME_pop_free(s->s3->tmp.ca_names,X509_NAME_free);
  2063. if (s->s3->rrec.comp != NULL)
  2064. {
  2065. OPENSSL_free(s->s3->rrec.comp);
  2066. s->s3->rrec.comp=NULL;
  2067. }
  2068. #ifndef OPENSSL_NO_DH
  2069. if (s->s3->tmp.dh != NULL)
  2070. DH_free(s->s3->tmp.dh);
  2071. #endif
  2072. #ifndef OPENSSL_NO_ECDH
  2073. if (s->s3->tmp.ecdh != NULL)
  2074. EC_KEY_free(s->s3->tmp.ecdh);
  2075. #endif
  2076. rp = s->s3->rbuf.buf;
  2077. wp = s->s3->wbuf.buf;
  2078. rlen = s->s3->rbuf.len;
  2079. wlen = s->s3->wbuf.len;
  2080. if (s->s3->handshake_buffer) {
  2081. BIO_free(s->s3->handshake_buffer);
  2082. }
  2083. if (s->s3->handshake_dgst) {
  2084. ssl3_free_digest_list(s);
  2085. }
  2086. memset(s->s3,0,sizeof *s->s3);
  2087. s->s3->rbuf.buf = rp;
  2088. s->s3->wbuf.buf = wp;
  2089. s->s3->rbuf.len = rlen;
  2090. s->s3->wbuf.len = wlen;
  2091. ssl_free_wbio_buffer(s);
  2092. s->packet_length=0;
  2093. s->s3->renegotiate=0;
  2094. s->s3->total_renegotiations=0;
  2095. s->s3->num_renegotiations=0;
  2096. s->s3->in_read_app_data=0;
  2097. s->version=SSL3_VERSION;
  2098. }
  2099. long ssl3_ctrl(SSL *s, int cmd, long larg, void *parg)
  2100. {
  2101. int ret=0;
  2102. #if !defined(OPENSSL_NO_DSA) || !defined(OPENSSL_NO_RSA)
  2103. if (
  2104. #ifndef OPENSSL_NO_RSA
  2105. cmd == SSL_CTRL_SET_TMP_RSA ||
  2106. cmd == SSL_CTRL_SET_TMP_RSA_CB ||
  2107. #endif
  2108. #ifndef OPENSSL_NO_DSA
  2109. cmd == SSL_CTRL_SET_TMP_DH ||
  2110. cmd == SSL_CTRL_SET_TMP_DH_CB ||
  2111. #endif
  2112. 0)
  2113. {
  2114. if (!ssl_cert_inst(&s->cert))
  2115. {
  2116. SSLerr(SSL_F_SSL3_CTRL, ERR_R_MALLOC_FAILURE);
  2117. return(0);
  2118. }
  2119. }
  2120. #endif
  2121. switch (cmd)
  2122. {
  2123. case SSL_CTRL_GET_SESSION_REUSED:
  2124. ret=s->hit;
  2125. break;
  2126. case SSL_CTRL_GET_CLIENT_CERT_REQUEST:
  2127. break;
  2128. case SSL_CTRL_GET_NUM_RENEGOTIATIONS:
  2129. ret=s->s3->num_renegotiations;
  2130. break;
  2131. case SSL_CTRL_CLEAR_NUM_RENEGOTIATIONS:
  2132. ret=s->s3->num_renegotiations;
  2133. s->s3->num_renegotiations=0;
  2134. break;
  2135. case SSL_CTRL_GET_TOTAL_RENEGOTIATIONS:
  2136. ret=s->s3->total_renegotiations;
  2137. break;
  2138. case SSL_CTRL_GET_FLAGS:
  2139. ret=(int)(s->s3->flags);
  2140. break;
  2141. #ifndef OPENSSL_NO_RSA
  2142. case SSL_CTRL_NEED_TMP_RSA:
  2143. if ((s->cert != NULL) && (s->cert->rsa_tmp == NULL) &&
  2144. ((s->cert->pkeys[SSL_PKEY_RSA_ENC].privatekey == NULL) ||
  2145. (EVP_PKEY_size(s->cert->pkeys[SSL_PKEY_RSA_ENC].privatekey) > (512/8))))
  2146. ret = 1;
  2147. break;
  2148. case SSL_CTRL_SET_TMP_RSA:
  2149. {
  2150. RSA *rsa = (RSA *)parg;
  2151. if (rsa == NULL)
  2152. {
  2153. SSLerr(SSL_F_SSL3_CTRL, ERR_R_PASSED_NULL_PARAMETER);
  2154. return(ret);
  2155. }
  2156. if ((rsa = RSAPrivateKey_dup(rsa)) == NULL)
  2157. {
  2158. SSLerr(SSL_F_SSL3_CTRL, ERR_R_RSA_LIB);
  2159. return(ret);
  2160. }
  2161. if (s->cert->rsa_tmp != NULL)
  2162. RSA_free(s->cert->rsa_tmp);
  2163. s->cert->rsa_tmp = rsa;
  2164. ret = 1;
  2165. }
  2166. break;
  2167. case SSL_CTRL_SET_TMP_RSA_CB:
  2168. {
  2169. SSLerr(SSL_F_SSL3_CTRL, ERR_R_SHOULD_NOT_HAVE_BEEN_CALLED);
  2170. return(ret);
  2171. }
  2172. break;
  2173. #endif
  2174. #ifndef OPENSSL_NO_DH
  2175. case SSL_CTRL_SET_TMP_DH:
  2176. {
  2177. DH *dh = (DH *)parg;
  2178. if (dh == NULL)
  2179. {
  2180. SSLerr(SSL_F_SSL3_CTRL, ERR_R_PASSED_NULL_PARAMETER);
  2181. return(ret);
  2182. }
  2183. if ((dh = DHparams_dup(dh)) == NULL)
  2184. {
  2185. SSLerr(SSL_F_SSL3_CTRL, ERR_R_DH_LIB);
  2186. return(ret);
  2187. }
  2188. if (!(s->options & SSL_OP_SINGLE_DH_USE))
  2189. {
  2190. if (!DH_generate_key(dh))
  2191. {
  2192. DH_free(dh);
  2193. SSLerr(SSL_F_SSL3_CTRL, ERR_R_DH_LIB);
  2194. return(ret);
  2195. }
  2196. }
  2197. if (s->cert->dh_tmp != NULL)
  2198. DH_free(s->cert->dh_tmp);
  2199. s->cert->dh_tmp = dh;
  2200. ret = 1;
  2201. }
  2202. break;
  2203. case SSL_CTRL_SET_TMP_DH_CB:
  2204. {
  2205. SSLerr(SSL_F_SSL3_CTRL, ERR_R_SHOULD_NOT_HAVE_BEEN_CALLED);
  2206. return(ret);
  2207. }
  2208. break;
  2209. #endif
  2210. #ifndef OPENSSL_NO_ECDH
  2211. case SSL_CTRL_SET_TMP_ECDH:
  2212. {
  2213. EC_KEY *ecdh = NULL;
  2214. if (parg == NULL)
  2215. {
  2216. SSLerr(SSL_F_SSL3_CTRL, ERR_R_PASSED_NULL_PARAMETER);
  2217. return(ret);
  2218. }
  2219. if (!EC_KEY_up_ref((EC_KEY *)parg))
  2220. {
  2221. SSLerr(SSL_F_SSL3_CTRL,ERR_R_ECDH_LIB);
  2222. return(ret);
  2223. }
  2224. ecdh = (EC_KEY *)parg;
  2225. if (!(s->options & SSL_OP_SINGLE_ECDH_USE))
  2226. {
  2227. if (!EC_KEY_generate_key(ecdh))
  2228. {
  2229. EC_KEY_free(ecdh);
  2230. SSLerr(SSL_F_SSL3_CTRL,ERR_R_ECDH_LIB);
  2231. return(ret);
  2232. }
  2233. }
  2234. if (s->cert->ecdh_tmp != NULL)
  2235. EC_KEY_free(s->cert->ecdh_tmp);
  2236. s->cert->ecdh_tmp = ecdh;
  2237. ret = 1;
  2238. }
  2239. break;
  2240. case SSL_CTRL_SET_TMP_ECDH_CB:
  2241. {
  2242. SSLerr(SSL_F_SSL3_CTRL, ERR_R_SHOULD_NOT_HAVE_BEEN_CALLED);
  2243. return(ret);
  2244. }
  2245. break;
  2246. #endif /* !OPENSSL_NO_ECDH */
  2247. #ifndef OPENSSL_NO_TLSEXT
  2248. case SSL_CTRL_SET_TLSEXT_HOSTNAME:
  2249. if (larg == TLSEXT_NAMETYPE_host_name)
  2250. {
  2251. if (s->tlsext_hostname != NULL)
  2252. OPENSSL_free(s->tlsext_hostname);
  2253. s->tlsext_hostname = NULL;
  2254. ret = 1;
  2255. if (parg == NULL)
  2256. break;
  2257. if (strlen((char *)parg) > TLSEXT_MAXLEN_host_name)
  2258. {
  2259. SSLerr(SSL_F_SSL3_CTRL, SSL_R_SSL3_EXT_INVALID_SERVERNAME);
  2260. return 0;
  2261. }
  2262. if ((s->tlsext_hostname = BUF_strdup((char *)parg)) == NULL)
  2263. {
  2264. SSLerr(SSL_F_SSL3_CTRL, ERR_R_INTERNAL_ERROR);
  2265. return 0;
  2266. }
  2267. }
  2268. else
  2269. {
  2270. SSLerr(SSL_F_SSL3_CTRL, SSL_R_SSL3_EXT_INVALID_SERVERNAME_TYPE);
  2271. return 0;
  2272. }
  2273. break;
  2274. case SSL_CTRL_SET_TLSEXT_DEBUG_ARG:
  2275. s->tlsext_debug_arg=parg;
  2276. ret = 1;
  2277. break;
  2278. #ifdef TLSEXT_TYPE_opaque_prf_input
  2279. case SSL_CTRL_SET_TLSEXT_OPAQUE_PRF_INPUT:
  2280. if (larg > 12288) /* actual internal limit is 2^16 for the complete hello message
  2281. * (including the cert chain and everything) */
  2282. {
  2283. SSLerr(SSL_F_SSL3_CTRL, SSL_R_OPAQUE_PRF_INPUT_TOO_LONG);
  2284. break;
  2285. }
  2286. if (s->tlsext_opaque_prf_input != NULL)
  2287. OPENSSL_free(s->tlsext_opaque_prf_input);
  2288. if ((size_t)larg == 0)
  2289. s->tlsext_opaque_prf_input = OPENSSL_malloc(1); /* dummy byte just to get non-NULL */
  2290. else
  2291. s->tlsext_opaque_prf_input = BUF_memdup(parg, (size_t)larg);
  2292. if (s->tlsext_opaque_prf_input != NULL)
  2293. {
  2294. s->tlsext_opaque_prf_input_len = (size_t)larg;
  2295. ret = 1;
  2296. }
  2297. else
  2298. s->tlsext_opaque_prf_input_len = 0;
  2299. break;
  2300. #endif
  2301. case SSL_CTRL_SET_TLSEXT_STATUS_REQ_TYPE:
  2302. s->tlsext_status_type=larg;
  2303. ret = 1;
  2304. break;
  2305. case SSL_CTRL_GET_TLSEXT_STATUS_REQ_EXTS:
  2306. *(STACK_OF(X509_EXTENSION) **)parg = s->tlsext_ocsp_exts;
  2307. ret = 1;
  2308. break;
  2309. case SSL_CTRL_SET_TLSEXT_STATUS_REQ_EXTS:
  2310. s->tlsext_ocsp_exts = parg;
  2311. ret = 1;
  2312. break;
  2313. case SSL_CTRL_GET_TLSEXT_STATUS_REQ_IDS:
  2314. *(STACK_OF(OCSP_RESPID) **)parg = s->tlsext_ocsp_ids;
  2315. ret = 1;
  2316. break;
  2317. case SSL_CTRL_SET_TLSEXT_STATUS_REQ_IDS:
  2318. s->tlsext_ocsp_ids = parg;
  2319. ret = 1;
  2320. break;
  2321. case SSL_CTRL_GET_TLSEXT_STATUS_REQ_OCSP_RESP:
  2322. *(unsigned char **)parg = s->tlsext_ocsp_resp;
  2323. return s->tlsext_ocsp_resplen;
  2324. case SSL_CTRL_SET_TLSEXT_STATUS_REQ_OCSP_RESP:
  2325. if (s->tlsext_ocsp_resp)
  2326. OPENSSL_free(s->tlsext_ocsp_resp);
  2327. s->tlsext_ocsp_resp = parg;
  2328. s->tlsext_ocsp_resplen = larg;
  2329. ret = 1;
  2330. break;
  2331. #endif /* !OPENSSL_NO_TLSEXT */
  2332. default:
  2333. break;
  2334. }
  2335. return(ret);
  2336. }
  2337. long ssl3_callback_ctrl(SSL *s, int cmd, void (*fp)(void))
  2338. {
  2339. int ret=0;
  2340. #if !defined(OPENSSL_NO_DSA) || !defined(OPENSSL_NO_RSA)
  2341. if (
  2342. #ifndef OPENSSL_NO_RSA
  2343. cmd == SSL_CTRL_SET_TMP_RSA_CB ||
  2344. #endif
  2345. #ifndef OPENSSL_NO_DSA
  2346. cmd == SSL_CTRL_SET_TMP_DH_CB ||
  2347. #endif
  2348. 0)
  2349. {
  2350. if (!ssl_cert_inst(&s->cert))
  2351. {
  2352. SSLerr(SSL_F_SSL3_CALLBACK_CTRL, ERR_R_MALLOC_FAILURE);
  2353. return(0);
  2354. }
  2355. }
  2356. #endif
  2357. switch (cmd)
  2358. {
  2359. #ifndef OPENSSL_NO_RSA
  2360. case SSL_CTRL_SET_TMP_RSA_CB:
  2361. {
  2362. s->cert->rsa_tmp_cb = (RSA *(*)(SSL *, int, int))fp;
  2363. }
  2364. break;
  2365. #endif
  2366. #ifndef OPENSSL_NO_DH
  2367. case SSL_CTRL_SET_TMP_DH_CB:
  2368. {
  2369. s->cert->dh_tmp_cb = (DH *(*)(SSL *, int, int))fp;
  2370. }
  2371. break;
  2372. #endif
  2373. #ifndef OPENSSL_NO_ECDH
  2374. case SSL_CTRL_SET_TMP_ECDH_CB:
  2375. {
  2376. s->cert->ecdh_tmp_cb = (EC_KEY *(*)(SSL *, int, int))fp;
  2377. }
  2378. break;
  2379. #endif
  2380. #ifndef OPENSSL_NO_TLSEXT
  2381. case SSL_CTRL_SET_TLSEXT_DEBUG_CB:
  2382. s->tlsext_debug_cb=(void (*)(SSL *,int ,int,
  2383. unsigned char *, int, void *))fp;
  2384. break;
  2385. #endif
  2386. default:
  2387. break;
  2388. }
  2389. return(ret);
  2390. }
  2391. long ssl3_ctx_ctrl(SSL_CTX *ctx, int cmd, long larg, void *parg)
  2392. {
  2393. CERT *cert;
  2394. cert=ctx->cert;
  2395. switch (cmd)
  2396. {
  2397. #ifndef OPENSSL_NO_RSA
  2398. case SSL_CTRL_NEED_TMP_RSA:
  2399. if ( (cert->rsa_tmp == NULL) &&
  2400. ((cert->pkeys[SSL_PKEY_RSA_ENC].privatekey == NULL) ||
  2401. (EVP_PKEY_size(cert->pkeys[SSL_PKEY_RSA_ENC].privatekey) > (512/8)))
  2402. )
  2403. return(1);
  2404. else
  2405. return(0);
  2406. /* break; */
  2407. case SSL_CTRL_SET_TMP_RSA:
  2408. {
  2409. RSA *rsa;
  2410. int i;
  2411. rsa=(RSA *)parg;
  2412. i=1;
  2413. if (rsa == NULL)
  2414. i=0;
  2415. else
  2416. {
  2417. if ((rsa=RSAPrivateKey_dup(rsa)) == NULL)
  2418. i=0;
  2419. }
  2420. if (!i)
  2421. {
  2422. SSLerr(SSL_F_SSL3_CTX_CTRL,ERR_R_RSA_LIB);
  2423. return(0);
  2424. }
  2425. else
  2426. {
  2427. if (cert->rsa_tmp != NULL)
  2428. RSA_free(cert->rsa_tmp);
  2429. cert->rsa_tmp=rsa;
  2430. return(1);
  2431. }
  2432. }
  2433. /* break; */
  2434. case SSL_CTRL_SET_TMP_RSA_CB:
  2435. {
  2436. SSLerr(SSL_F_SSL3_CTX_CTRL, ERR_R_SHOULD_NOT_HAVE_BEEN_CALLED);
  2437. return(0);
  2438. }
  2439. break;
  2440. #endif
  2441. #ifndef OPENSSL_NO_DH
  2442. case SSL_CTRL_SET_TMP_DH:
  2443. {
  2444. DH *new=NULL,*dh;
  2445. dh=(DH *)parg;
  2446. if ((new=DHparams_dup(dh)) == NULL)
  2447. {
  2448. SSLerr(SSL_F_SSL3_CTX_CTRL,ERR_R_DH_LIB);
  2449. return 0;
  2450. }
  2451. if (!(ctx->options & SSL_OP_SINGLE_DH_USE))
  2452. {
  2453. if (!DH_generate_key(new))
  2454. {
  2455. SSLerr(SSL_F_SSL3_CTX_CTRL,ERR_R_DH_LIB);
  2456. DH_free(new);
  2457. return 0;
  2458. }
  2459. }
  2460. if (cert->dh_tmp != NULL)
  2461. DH_free(cert->dh_tmp);
  2462. cert->dh_tmp=new;
  2463. return 1;
  2464. }
  2465. /*break; */
  2466. case SSL_CTRL_SET_TMP_DH_CB:
  2467. {
  2468. SSLerr(SSL_F_SSL3_CTX_CTRL, ERR_R_SHOULD_NOT_HAVE_BEEN_CALLED);
  2469. return(0);
  2470. }
  2471. break;
  2472. #endif
  2473. #ifndef OPENSSL_NO_ECDH
  2474. case SSL_CTRL_SET_TMP_ECDH:
  2475. {
  2476. EC_KEY *ecdh = NULL;
  2477. if (parg == NULL)
  2478. {
  2479. SSLerr(SSL_F_SSL3_CTX_CTRL,ERR_R_ECDH_LIB);
  2480. return 0;
  2481. }
  2482. ecdh = EC_KEY_dup((EC_KEY *)parg);
  2483. if (ecdh == NULL)
  2484. {
  2485. SSLerr(SSL_F_SSL3_CTX_CTRL,ERR_R_EC_LIB);
  2486. return 0;
  2487. }
  2488. if (!(ctx->options & SSL_OP_SINGLE_ECDH_USE))
  2489. {
  2490. if (!EC_KEY_generate_key(ecdh))
  2491. {
  2492. EC_KEY_free(ecdh);
  2493. SSLerr(SSL_F_SSL3_CTX_CTRL,ERR_R_ECDH_LIB);
  2494. return 0;
  2495. }
  2496. }
  2497. if (cert->ecdh_tmp != NULL)
  2498. {
  2499. EC_KEY_free(cert->ecdh_tmp);
  2500. }
  2501. cert->ecdh_tmp = ecdh;
  2502. return 1;
  2503. }
  2504. /* break; */
  2505. case SSL_CTRL_SET_TMP_ECDH_CB:
  2506. {
  2507. SSLerr(SSL_F_SSL3_CTX_CTRL, ERR_R_SHOULD_NOT_HAVE_BEEN_CALLED);
  2508. return(0);
  2509. }
  2510. break;
  2511. #endif /* !OPENSSL_NO_ECDH */
  2512. #ifndef OPENSSL_NO_TLSEXT
  2513. case SSL_CTRL_SET_TLSEXT_SERVERNAME_ARG:
  2514. ctx->tlsext_servername_arg=parg;
  2515. break;
  2516. case SSL_CTRL_SET_TLSEXT_TICKET_KEYS:
  2517. case SSL_CTRL_GET_TLSEXT_TICKET_KEYS:
  2518. {
  2519. unsigned char *keys = parg;
  2520. if (!keys)
  2521. return 48;
  2522. if (larg != 48)
  2523. {
  2524. SSLerr(SSL_F_SSL3_CTX_CTRL, SSL_R_INVALID_TICKET_KEYS_LENGTH);
  2525. return 0;
  2526. }
  2527. if (cmd == SSL_CTRL_SET_TLSEXT_TICKET_KEYS)
  2528. {
  2529. memcpy(ctx->tlsext_tick_key_name, keys, 16);
  2530. memcpy(ctx->tlsext_tick_hmac_key, keys + 16, 16);
  2531. memcpy(ctx->tlsext_tick_aes_key, keys + 32, 16);
  2532. }
  2533. else
  2534. {
  2535. memcpy(keys, ctx->tlsext_tick_key_name, 16);
  2536. memcpy(keys + 16, ctx->tlsext_tick_hmac_key, 16);
  2537. memcpy(keys + 32, ctx->tlsext_tick_aes_key, 16);
  2538. }
  2539. return 1;
  2540. }
  2541. #ifdef TLSEXT_TYPE_opaque_prf_input
  2542. case SSL_CTRL_SET_TLSEXT_OPAQUE_PRF_INPUT_CB_ARG:
  2543. ctx->tlsext_opaque_prf_input_callback_arg = parg;
  2544. return 1;
  2545. #endif
  2546. case SSL_CTRL_SET_TLSEXT_STATUS_REQ_CB_ARG:
  2547. ctx->tlsext_status_arg=parg;
  2548. return 1;
  2549. break;
  2550. #endif /* !OPENSSL_NO_TLSEXT */
  2551. /* A Thawte special :-) */
  2552. case SSL_CTRL_EXTRA_CHAIN_CERT:
  2553. if (ctx->extra_certs == NULL)
  2554. {
  2555. if ((ctx->extra_certs=sk_X509_new_null()) == NULL)
  2556. return(0);
  2557. }
  2558. sk_X509_push(ctx->extra_certs,(X509 *)parg);
  2559. break;
  2560. default:
  2561. return(0);
  2562. }
  2563. return(1);
  2564. }
  2565. long ssl3_ctx_callback_ctrl(SSL_CTX *ctx, int cmd, void (*fp)(void))
  2566. {
  2567. CERT *cert;
  2568. cert=ctx->cert;
  2569. switch (cmd)
  2570. {
  2571. #ifndef OPENSSL_NO_RSA
  2572. case SSL_CTRL_SET_TMP_RSA_CB:
  2573. {
  2574. cert->rsa_tmp_cb = (RSA *(*)(SSL *, int, int))fp;
  2575. }
  2576. break;
  2577. #endif
  2578. #ifndef OPENSSL_NO_DH
  2579. case SSL_CTRL_SET_TMP_DH_CB:
  2580. {
  2581. cert->dh_tmp_cb = (DH *(*)(SSL *, int, int))fp;
  2582. }
  2583. break;
  2584. #endif
  2585. #ifndef OPENSSL_NO_ECDH
  2586. case SSL_CTRL_SET_TMP_ECDH_CB:
  2587. {
  2588. cert->ecdh_tmp_cb = (EC_KEY *(*)(SSL *, int, int))fp;
  2589. }
  2590. break;
  2591. #endif
  2592. #ifndef OPENSSL_NO_TLSEXT
  2593. case SSL_CTRL_SET_TLSEXT_SERVERNAME_CB:
  2594. ctx->tlsext_servername_callback=(int (*)(SSL *,int *,void *))fp;
  2595. break;
  2596. #ifdef TLSEXT_TYPE_opaque_prf_input
  2597. case SSL_CTRL_SET_TLSEXT_OPAQUE_PRF_INPUT_CB:
  2598. ctx->tlsext_opaque_prf_input_callback = (int (*)(SSL *,void *, size_t, void *))fp;
  2599. break;
  2600. #endif
  2601. case SSL_CTRL_SET_TLSEXT_STATUS_REQ_CB:
  2602. ctx->tlsext_status_cb=(int (*)(SSL *,void *))fp;
  2603. break;
  2604. case SSL_CTRL_SET_TLSEXT_TICKET_KEY_CB:
  2605. ctx->tlsext_ticket_key_cb=(int (*)(SSL *,unsigned char *,
  2606. unsigned char *,
  2607. EVP_CIPHER_CTX *,
  2608. HMAC_CTX *, int))fp;
  2609. break;
  2610. #endif
  2611. default:
  2612. return(0);
  2613. }
  2614. return(1);
  2615. }
  2616. /* This function needs to check if the ciphers required are actually
  2617. * available */
  2618. SSL_CIPHER *ssl3_get_cipher_by_char(const unsigned char *p)
  2619. {
  2620. SSL_CIPHER c,*cp;
  2621. unsigned long id;
  2622. id=0x03000000L|((unsigned long)p[0]<<8L)|(unsigned long)p[1];
  2623. c.id=id;
  2624. cp = (SSL_CIPHER *)OBJ_bsearch((char *)&c,
  2625. (char *)ssl3_ciphers,
  2626. SSL3_NUM_CIPHERS,sizeof(SSL_CIPHER),
  2627. FP_ICC ssl_cipher_id_cmp);
  2628. if (cp == NULL || cp->valid == 0)
  2629. return NULL;
  2630. else
  2631. return cp;
  2632. }
  2633. int ssl3_put_cipher_by_char(const SSL_CIPHER *c, unsigned char *p)
  2634. {
  2635. long l;
  2636. if (p != NULL)
  2637. {
  2638. l=c->id;
  2639. if ((l & 0xff000000) != 0x03000000) return(0);
  2640. p[0]=((unsigned char)(l>> 8L))&0xFF;
  2641. p[1]=((unsigned char)(l ))&0xFF;
  2642. }
  2643. return(2);
  2644. }
  2645. SSL_CIPHER *ssl3_choose_cipher(SSL *s, STACK_OF(SSL_CIPHER) *clnt,
  2646. STACK_OF(SSL_CIPHER) *srvr)
  2647. {
  2648. SSL_CIPHER *c,*ret=NULL;
  2649. STACK_OF(SSL_CIPHER) *prio, *allow;
  2650. int i,ii,ok;
  2651. #ifndef OPENSSL_NO_TLSEXT
  2652. unsigned int j;
  2653. #ifndef OPENSSL_NO_EC
  2654. int ec_ok, ec_nid;
  2655. unsigned char ec_search1 = 0, ec_search2 = 0;
  2656. #endif /* OPENSSL_NO_EC */
  2657. #endif /* OPENSSL_NO_TLSEXT */
  2658. CERT *cert;
  2659. unsigned long alg_k,alg_a,mask_k,mask_a,emask_k,emask_a;
  2660. /* Let's see which ciphers we can support */
  2661. cert=s->cert;
  2662. #if 0
  2663. /* Do not set the compare functions, because this may lead to a
  2664. * reordering by "id". We want to keep the original ordering.
  2665. * We may pay a price in performance during sk_SSL_CIPHER_find(),
  2666. * but would have to pay with the price of sk_SSL_CIPHER_dup().
  2667. */
  2668. sk_SSL_CIPHER_set_cmp_func(srvr, ssl_cipher_ptr_id_cmp);
  2669. sk_SSL_CIPHER_set_cmp_func(clnt, ssl_cipher_ptr_id_cmp);
  2670. #endif
  2671. #ifdef CIPHER_DEBUG
  2672. printf("Server has %d from %p:\n", sk_SSL_CIPHER_num(srvr), (void *)srvr);
  2673. for(i=0 ; i < sk_SSL_CIPHER_num(srvr) ; ++i)
  2674. {
  2675. c=sk_SSL_CIPHER_value(srvr,i);
  2676. printf("%p:%s\n",(void *)c,c->name);
  2677. }
  2678. printf("Client sent %d from %p:\n", sk_SSL_CIPHER_num(clnt), (void *)clnt);
  2679. for(i=0 ; i < sk_SSL_CIPHER_num(clnt) ; ++i)
  2680. {
  2681. c=sk_SSL_CIPHER_value(clnt,i);
  2682. printf("%p:%s\n",(void *)c,c->name);
  2683. }
  2684. #endif
  2685. if (s->options & SSL_OP_CIPHER_SERVER_PREFERENCE)
  2686. {
  2687. prio = srvr;
  2688. allow = clnt;
  2689. }
  2690. else
  2691. {
  2692. prio = clnt;
  2693. allow = srvr;
  2694. }
  2695. for (i=0; i<sk_SSL_CIPHER_num(prio); i++)
  2696. {
  2697. c=sk_SSL_CIPHER_value(prio,i);
  2698. ssl_set_cert_masks(cert,c);
  2699. mask_k = cert->mask_k;
  2700. mask_a = cert->mask_a;
  2701. emask_k = cert->export_mask_k;
  2702. emask_a = cert->export_mask_a;
  2703. #ifdef KSSL_DEBUG
  2704. /* printf("ssl3_choose_cipher %d alg= %lx\n", i,c->algorithms);*/
  2705. #endif /* KSSL_DEBUG */
  2706. alg_k=c->algorithm_mkey;
  2707. alg_a=c->algorithm_auth;
  2708. #ifndef OPENSSL_NO_KRB5
  2709. if (alg_k & SSL_kKRB5)
  2710. {
  2711. if ( !kssl_keytab_is_available(s->kssl_ctx) )
  2712. continue;
  2713. }
  2714. #endif /* OPENSSL_NO_KRB5 */
  2715. #ifndef OPENSSL_NO_PSK
  2716. /* with PSK there must be server callback set */
  2717. if ((alg_k & SSL_kPSK) && s->psk_server_callback == NULL)
  2718. continue;
  2719. #endif /* OPENSSL_NO_PSK */
  2720. if (SSL_C_IS_EXPORT(c))
  2721. {
  2722. ok = (alg_k & emask_k) && (alg_a & emask_a);
  2723. #ifdef CIPHER_DEBUG
  2724. printf("%d:[%08lX:%08lX:%08lX:%08lX]%p:%s (export)\n",ok,alg_k,alg_a,emask_k,emask_a,
  2725. (void *)c,c->name);
  2726. #endif
  2727. }
  2728. else
  2729. {
  2730. ok = (alg_k & mask_k) && (alg_a & mask_a);
  2731. #ifdef CIPHER_DEBUG
  2732. printf("%d:[%08lX:%08lX:%08lX:%08lX]%p:%s\n",ok,alg_k,alg_a,mask_k,mask_a,(void *)c,
  2733. c->name);
  2734. #endif
  2735. }
  2736. #ifndef OPENSSL_NO_TLSEXT
  2737. #ifndef OPENSSL_NO_EC
  2738. if (
  2739. /* if we are considering an ECC cipher suite that uses our certificate */
  2740. (alg_a & SSL_aECDSA || alg_a & SSL_aECDH)
  2741. /* and we have an ECC certificate */
  2742. && (s->cert->pkeys[SSL_PKEY_ECC].x509 != NULL)
  2743. /* and the client specified a Supported Point Formats extension */
  2744. && ((s->session->tlsext_ecpointformatlist_length > 0) && (s->session->tlsext_ecpointformatlist != NULL))
  2745. /* and our certificate's point is compressed */
  2746. && (
  2747. (s->cert->pkeys[SSL_PKEY_ECC].x509->cert_info != NULL)
  2748. && (s->cert->pkeys[SSL_PKEY_ECC].x509->cert_info->key != NULL)
  2749. && (s->cert->pkeys[SSL_PKEY_ECC].x509->cert_info->key->public_key != NULL)
  2750. && (s->cert->pkeys[SSL_PKEY_ECC].x509->cert_info->key->public_key->data != NULL)
  2751. && (
  2752. (*(s->cert->pkeys[SSL_PKEY_ECC].x509->cert_info->key->public_key->data) == POINT_CONVERSION_COMPRESSED)
  2753. || (*(s->cert->pkeys[SSL_PKEY_ECC].x509->cert_info->key->public_key->data) == POINT_CONVERSION_COMPRESSED + 1)
  2754. )
  2755. )
  2756. )
  2757. {
  2758. ec_ok = 0;
  2759. /* if our certificate's curve is over a field type that the client does not support
  2760. * then do not allow this cipher suite to be negotiated */
  2761. if (
  2762. (s->cert->pkeys[SSL_PKEY_ECC].privatekey->pkey.ec != NULL)
  2763. && (s->cert->pkeys[SSL_PKEY_ECC].privatekey->pkey.ec->group != NULL)
  2764. && (s->cert->pkeys[SSL_PKEY_ECC].privatekey->pkey.ec->group->meth != NULL)
  2765. && (EC_METHOD_get_field_type(s->cert->pkeys[SSL_PKEY_ECC].privatekey->pkey.ec->group->meth) == NID_X9_62_prime_field)
  2766. )
  2767. {
  2768. for (j = 0; j < s->session->tlsext_ecpointformatlist_length; j++)
  2769. {
  2770. if (s->session->tlsext_ecpointformatlist[j] == TLSEXT_ECPOINTFORMAT_ansiX962_compressed_prime)
  2771. {
  2772. ec_ok = 1;
  2773. break;
  2774. }
  2775. }
  2776. }
  2777. else if (EC_METHOD_get_field_type(s->cert->pkeys[SSL_PKEY_ECC].privatekey->pkey.ec->group->meth) == NID_X9_62_characteristic_two_field)
  2778. {
  2779. for (j = 0; j < s->session->tlsext_ecpointformatlist_length; j++)
  2780. {
  2781. if (s->session->tlsext_ecpointformatlist[j] == TLSEXT_ECPOINTFORMAT_ansiX962_compressed_char2)
  2782. {
  2783. ec_ok = 1;
  2784. break;
  2785. }
  2786. }
  2787. }
  2788. ok = ok && ec_ok;
  2789. }
  2790. if (
  2791. /* if we are considering an ECC cipher suite that uses our certificate */
  2792. (alg_a & SSL_aECDSA || alg_a & SSL_aECDH)
  2793. /* and we have an ECC certificate */
  2794. && (s->cert->pkeys[SSL_PKEY_ECC].x509 != NULL)
  2795. /* and the client specified an EllipticCurves extension */
  2796. && ((s->session->tlsext_ellipticcurvelist_length > 0) && (s->session->tlsext_ellipticcurvelist != NULL))
  2797. )
  2798. {
  2799. ec_ok = 0;
  2800. if (
  2801. (s->cert->pkeys[SSL_PKEY_ECC].privatekey->pkey.ec != NULL)
  2802. && (s->cert->pkeys[SSL_PKEY_ECC].privatekey->pkey.ec->group != NULL)
  2803. )
  2804. {
  2805. ec_nid = EC_GROUP_get_curve_name(s->cert->pkeys[SSL_PKEY_ECC].privatekey->pkey.ec->group);
  2806. if ((ec_nid == 0)
  2807. && (s->cert->pkeys[SSL_PKEY_ECC].privatekey->pkey.ec->group->meth != NULL)
  2808. )
  2809. {
  2810. if (EC_METHOD_get_field_type(s->cert->pkeys[SSL_PKEY_ECC].privatekey->pkey.ec->group->meth) == NID_X9_62_prime_field)
  2811. {
  2812. ec_search1 = 0xFF;
  2813. ec_search2 = 0x01;
  2814. }
  2815. else if (EC_METHOD_get_field_type(s->cert->pkeys[SSL_PKEY_ECC].privatekey->pkey.ec->group->meth) == NID_X9_62_characteristic_two_field)
  2816. {
  2817. ec_search1 = 0xFF;
  2818. ec_search2 = 0x02;
  2819. }
  2820. }
  2821. else
  2822. {
  2823. ec_search1 = 0x00;
  2824. ec_search2 = tls1_ec_nid2curve_id(ec_nid);
  2825. }
  2826. if ((ec_search1 != 0) || (ec_search2 != 0))
  2827. {
  2828. for (j = 0; j < s->session->tlsext_ellipticcurvelist_length / 2; j++)
  2829. {
  2830. if ((s->session->tlsext_ellipticcurvelist[2*j] == ec_search1) && (s->session->tlsext_ellipticcurvelist[2*j+1] == ec_search2))
  2831. {
  2832. ec_ok = 1;
  2833. break;
  2834. }
  2835. }
  2836. }
  2837. }
  2838. ok = ok && ec_ok;
  2839. }
  2840. if (
  2841. /* if we are considering an ECC cipher suite that uses an ephemeral EC key */
  2842. (alg_k & SSL_kEECDH)
  2843. /* and we have an ephemeral EC key */
  2844. && (s->cert->ecdh_tmp != NULL)
  2845. /* and the client specified an EllipticCurves extension */
  2846. && ((s->session->tlsext_ellipticcurvelist_length > 0) && (s->session->tlsext_ellipticcurvelist != NULL))
  2847. )
  2848. {
  2849. ec_ok = 0;
  2850. if (s->cert->ecdh_tmp->group != NULL)
  2851. {
  2852. ec_nid = EC_GROUP_get_curve_name(s->cert->ecdh_tmp->group);
  2853. if ((ec_nid == 0)
  2854. && (s->cert->ecdh_tmp->group->meth != NULL)
  2855. )
  2856. {
  2857. if (EC_METHOD_get_field_type(s->cert->ecdh_tmp->group->meth) == NID_X9_62_prime_field)
  2858. {
  2859. ec_search1 = 0xFF;
  2860. ec_search2 = 0x01;
  2861. }
  2862. else if (EC_METHOD_get_field_type(s->cert->ecdh_tmp->group->meth) == NID_X9_62_characteristic_two_field)
  2863. {
  2864. ec_search1 = 0xFF;
  2865. ec_search2 = 0x02;
  2866. }
  2867. }
  2868. else
  2869. {
  2870. ec_search1 = 0x00;
  2871. ec_search2 = tls1_ec_nid2curve_id(ec_nid);
  2872. }
  2873. if ((ec_search1 != 0) || (ec_search2 != 0))
  2874. {
  2875. for (j = 0; j < s->session->tlsext_ellipticcurvelist_length / 2; j++)
  2876. {
  2877. if ((s->session->tlsext_ellipticcurvelist[2*j] == ec_search1) && (s->session->tlsext_ellipticcurvelist[2*j+1] == ec_search2))
  2878. {
  2879. ec_ok = 1;
  2880. break;
  2881. }
  2882. }
  2883. }
  2884. }
  2885. ok = ok && ec_ok;
  2886. }
  2887. #endif /* OPENSSL_NO_EC */
  2888. #endif /* OPENSSL_NO_TLSEXT */
  2889. if (!ok) continue;
  2890. ii=sk_SSL_CIPHER_find(allow,c);
  2891. if (ii >= 0)
  2892. {
  2893. ret=sk_SSL_CIPHER_value(allow,ii);
  2894. break;
  2895. }
  2896. }
  2897. return(ret);
  2898. }
  2899. int ssl3_get_req_cert_type(SSL *s, unsigned char *p)
  2900. {
  2901. int ret=0;
  2902. unsigned long alg_k;
  2903. alg_k = s->s3->tmp.new_cipher->algorithm_mkey;
  2904. #ifndef OPENSSL_NO_DH
  2905. if (alg_k & (SSL_kDHr|SSL_kEDH))
  2906. {
  2907. # ifndef OPENSSL_NO_RSA
  2908. p[ret++]=SSL3_CT_RSA_FIXED_DH;
  2909. # endif
  2910. # ifndef OPENSSL_NO_DSA
  2911. p[ret++]=SSL3_CT_DSS_FIXED_DH;
  2912. # endif
  2913. }
  2914. if ((s->version == SSL3_VERSION) &&
  2915. (alg_k & (SSL_kEDH|SSL_kDHd|SSL_kDHr)))
  2916. {
  2917. # ifndef OPENSSL_NO_RSA
  2918. p[ret++]=SSL3_CT_RSA_EPHEMERAL_DH;
  2919. # endif
  2920. # ifndef OPENSSL_NO_DSA
  2921. p[ret++]=SSL3_CT_DSS_EPHEMERAL_DH;
  2922. # endif
  2923. }
  2924. #endif /* !OPENSSL_NO_DH */
  2925. #ifndef OPENSSL_NO_RSA
  2926. p[ret++]=SSL3_CT_RSA_SIGN;
  2927. #endif
  2928. #ifndef OPENSSL_NO_DSA
  2929. p[ret++]=SSL3_CT_DSS_SIGN;
  2930. #endif
  2931. #ifndef OPENSSL_NO_ECDH
  2932. if ((alg_k & (SSL_kECDHr|SSL_kECDHe)) && (s->version >= TLS1_VERSION))
  2933. {
  2934. p[ret++]=TLS_CT_RSA_FIXED_ECDH;
  2935. p[ret++]=TLS_CT_ECDSA_FIXED_ECDH;
  2936. }
  2937. #endif
  2938. #ifndef OPENSSL_NO_ECDSA
  2939. /* ECDSA certs can be used with RSA cipher suites as well
  2940. * so we don't need to check for SSL_kECDH or SSL_kEECDH
  2941. */
  2942. if (s->version >= TLS1_VERSION)
  2943. {
  2944. p[ret++]=TLS_CT_ECDSA_SIGN;
  2945. }
  2946. #endif
  2947. return(ret);
  2948. }
  2949. int ssl3_shutdown(SSL *s)
  2950. {
  2951. /* Don't do anything much if we have not done the handshake or
  2952. * we don't want to send messages :-) */
  2953. if ((s->quiet_shutdown) || (s->state == SSL_ST_BEFORE))
  2954. {
  2955. s->shutdown=(SSL_SENT_SHUTDOWN|SSL_RECEIVED_SHUTDOWN);
  2956. return(1);
  2957. }
  2958. if (!(s->shutdown & SSL_SENT_SHUTDOWN))
  2959. {
  2960. s->shutdown|=SSL_SENT_SHUTDOWN;
  2961. #if 1
  2962. ssl3_send_alert(s,SSL3_AL_WARNING,SSL_AD_CLOSE_NOTIFY);
  2963. #endif
  2964. /* our shutdown alert has been sent now, and if it still needs
  2965. * to be written, s->s3->alert_dispatch will be true */
  2966. }
  2967. else if (s->s3->alert_dispatch)
  2968. {
  2969. /* resend it if not sent */
  2970. #if 1
  2971. s->method->ssl_dispatch_alert(s);
  2972. #endif
  2973. }
  2974. else if (!(s->shutdown & SSL_RECEIVED_SHUTDOWN))
  2975. {
  2976. /* If we are waiting for a close from our peer, we are closed */
  2977. s->method->ssl_read_bytes(s,0,NULL,0,0);
  2978. }
  2979. if ((s->shutdown == (SSL_SENT_SHUTDOWN|SSL_RECEIVED_SHUTDOWN)) &&
  2980. !s->s3->alert_dispatch)
  2981. return(1);
  2982. else
  2983. return(0);
  2984. }
  2985. int ssl3_write(SSL *s, const void *buf, int len)
  2986. {
  2987. int ret,n;
  2988. #if 0
  2989. if (s->shutdown & SSL_SEND_SHUTDOWN)
  2990. {
  2991. s->rwstate=SSL_NOTHING;
  2992. return(0);
  2993. }
  2994. #endif
  2995. clear_sys_error();
  2996. if (s->s3->renegotiate) ssl3_renegotiate_check(s);
  2997. /* This is an experimental flag that sends the
  2998. * last handshake message in the same packet as the first
  2999. * use data - used to see if it helps the TCP protocol during
  3000. * session-id reuse */
  3001. /* The second test is because the buffer may have been removed */
  3002. if ((s->s3->flags & SSL3_FLAGS_POP_BUFFER) && (s->wbio == s->bbio))
  3003. {
  3004. /* First time through, we write into the buffer */
  3005. if (s->s3->delay_buf_pop_ret == 0)
  3006. {
  3007. ret=ssl3_write_bytes(s,SSL3_RT_APPLICATION_DATA,
  3008. buf,len);
  3009. if (ret <= 0) return(ret);
  3010. s->s3->delay_buf_pop_ret=ret;
  3011. }
  3012. s->rwstate=SSL_WRITING;
  3013. n=BIO_flush(s->wbio);
  3014. if (n <= 0) return(n);
  3015. s->rwstate=SSL_NOTHING;
  3016. /* We have flushed the buffer, so remove it */
  3017. ssl_free_wbio_buffer(s);
  3018. s->s3->flags&= ~SSL3_FLAGS_POP_BUFFER;
  3019. ret=s->s3->delay_buf_pop_ret;
  3020. s->s3->delay_buf_pop_ret=0;
  3021. }
  3022. else
  3023. {
  3024. ret=s->method->ssl_write_bytes(s,SSL3_RT_APPLICATION_DATA,
  3025. buf,len);
  3026. if (ret <= 0) return(ret);
  3027. }
  3028. return(ret);
  3029. }
  3030. static int ssl3_read_internal(SSL *s, void *buf, int len, int peek)
  3031. {
  3032. int ret;
  3033. clear_sys_error();
  3034. if (s->s3->renegotiate) ssl3_renegotiate_check(s);
  3035. s->s3->in_read_app_data=1;
  3036. ret=s->method->ssl_read_bytes(s,SSL3_RT_APPLICATION_DATA,buf,len,peek);
  3037. if ((ret == -1) && (s->s3->in_read_app_data == 2))
  3038. {
  3039. /* ssl3_read_bytes decided to call s->handshake_func, which
  3040. * called ssl3_read_bytes to read handshake data.
  3041. * However, ssl3_read_bytes actually found application data
  3042. * and thinks that application data makes sense here; so disable
  3043. * handshake processing and try to read application data again. */
  3044. s->in_handshake++;
  3045. ret=s->method->ssl_read_bytes(s,SSL3_RT_APPLICATION_DATA,buf,len,peek);
  3046. s->in_handshake--;
  3047. }
  3048. else
  3049. s->s3->in_read_app_data=0;
  3050. return(ret);
  3051. }
  3052. int ssl3_read(SSL *s, void *buf, int len)
  3053. {
  3054. return ssl3_read_internal(s, buf, len, 0);
  3055. }
  3056. int ssl3_peek(SSL *s, void *buf, int len)
  3057. {
  3058. return ssl3_read_internal(s, buf, len, 1);
  3059. }
  3060. int ssl3_renegotiate(SSL *s)
  3061. {
  3062. if (s->handshake_func == NULL)
  3063. return(1);
  3064. if (s->s3->flags & SSL3_FLAGS_NO_RENEGOTIATE_CIPHERS)
  3065. return(0);
  3066. s->s3->renegotiate=1;
  3067. return(1);
  3068. }
  3069. int ssl3_renegotiate_check(SSL *s)
  3070. {
  3071. int ret=0;
  3072. if (s->s3->renegotiate)
  3073. {
  3074. if ( (s->s3->rbuf.left == 0) &&
  3075. (s->s3->wbuf.left == 0) &&
  3076. !SSL_in_init(s))
  3077. {
  3078. /*
  3079. if we are the server, and we have sent a 'RENEGOTIATE' message, we
  3080. need to go to SSL_ST_ACCEPT.
  3081. */
  3082. /* SSL_ST_ACCEPT */
  3083. s->state=SSL_ST_RENEGOTIATE;
  3084. s->s3->renegotiate=0;
  3085. s->s3->num_renegotiations++;
  3086. s->s3->total_renegotiations++;
  3087. ret=1;
  3088. }
  3089. }
  3090. return(ret);
  3091. }