s3_lib.c 64 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254325532563257325832593260326132623263326432653266326732683269327032713272327332743275327632773278327932803281328232833284328532863287328832893290329132923293329432953296329732983299330033013302330333043305330633073308330933103311331233133314331533163317331833193320332133223323332433253326332733283329
  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|SSL_FIPS,
  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|SSL_FIPS,
  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|SSL_FIPS,
  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|SSL_FIPS,
  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|SSL_FIPS,
  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|SSL_FIPS,
  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|SSL_FIPS,
  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|SSL_FIPS,
  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|SSL_FIPS,
  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|SSL_FIPS,
  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|SSL_FIPS,
  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|SSL_FIPS,
  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|SSL_FIPS,
  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|SSL_FIPS,
  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|SSL_FIPS,
  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|SSL_FIPS,
  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|SSL_FIPS,
  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|SSL_FIPS,
  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|SSL_FIPS,
  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|SSL_FIPS,
  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. n_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. const 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. ssl3_release_read_buffer(s);
  2026. if (s->s3->wbuf.buf != NULL)
  2027. ssl3_release_write_buffer(s);
  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. s->s3->handshake_buffer = NULL;
  2083. }
  2084. if (s->s3->handshake_dgst) {
  2085. ssl3_free_digest_list(s);
  2086. }
  2087. memset(s->s3,0,sizeof *s->s3);
  2088. s->s3->rbuf.buf = rp;
  2089. s->s3->wbuf.buf = wp;
  2090. s->s3->rbuf.len = rlen;
  2091. s->s3->wbuf.len = wlen;
  2092. ssl_free_wbio_buffer(s);
  2093. s->packet_length=0;
  2094. s->s3->renegotiate=0;
  2095. s->s3->total_renegotiations=0;
  2096. s->s3->num_renegotiations=0;
  2097. s->s3->in_read_app_data=0;
  2098. s->version=SSL3_VERSION;
  2099. }
  2100. long ssl3_ctrl(SSL *s, int cmd, long larg, void *parg)
  2101. {
  2102. int ret=0;
  2103. #if !defined(OPENSSL_NO_DSA) || !defined(OPENSSL_NO_RSA)
  2104. if (
  2105. #ifndef OPENSSL_NO_RSA
  2106. cmd == SSL_CTRL_SET_TMP_RSA ||
  2107. cmd == SSL_CTRL_SET_TMP_RSA_CB ||
  2108. #endif
  2109. #ifndef OPENSSL_NO_DSA
  2110. cmd == SSL_CTRL_SET_TMP_DH ||
  2111. cmd == SSL_CTRL_SET_TMP_DH_CB ||
  2112. #endif
  2113. 0)
  2114. {
  2115. if (!ssl_cert_inst(&s->cert))
  2116. {
  2117. SSLerr(SSL_F_SSL3_CTRL, ERR_R_MALLOC_FAILURE);
  2118. return(0);
  2119. }
  2120. }
  2121. #endif
  2122. switch (cmd)
  2123. {
  2124. case SSL_CTRL_GET_SESSION_REUSED:
  2125. ret=s->hit;
  2126. break;
  2127. case SSL_CTRL_GET_CLIENT_CERT_REQUEST:
  2128. break;
  2129. case SSL_CTRL_GET_NUM_RENEGOTIATIONS:
  2130. ret=s->s3->num_renegotiations;
  2131. break;
  2132. case SSL_CTRL_CLEAR_NUM_RENEGOTIATIONS:
  2133. ret=s->s3->num_renegotiations;
  2134. s->s3->num_renegotiations=0;
  2135. break;
  2136. case SSL_CTRL_GET_TOTAL_RENEGOTIATIONS:
  2137. ret=s->s3->total_renegotiations;
  2138. break;
  2139. case SSL_CTRL_GET_FLAGS:
  2140. ret=(int)(s->s3->flags);
  2141. break;
  2142. #ifndef OPENSSL_NO_RSA
  2143. case SSL_CTRL_NEED_TMP_RSA:
  2144. if ((s->cert != NULL) && (s->cert->rsa_tmp == NULL) &&
  2145. ((s->cert->pkeys[SSL_PKEY_RSA_ENC].privatekey == NULL) ||
  2146. (EVP_PKEY_size(s->cert->pkeys[SSL_PKEY_RSA_ENC].privatekey) > (512/8))))
  2147. ret = 1;
  2148. break;
  2149. case SSL_CTRL_SET_TMP_RSA:
  2150. {
  2151. RSA *rsa = (RSA *)parg;
  2152. if (rsa == NULL)
  2153. {
  2154. SSLerr(SSL_F_SSL3_CTRL, ERR_R_PASSED_NULL_PARAMETER);
  2155. return(ret);
  2156. }
  2157. if ((rsa = RSAPrivateKey_dup(rsa)) == NULL)
  2158. {
  2159. SSLerr(SSL_F_SSL3_CTRL, ERR_R_RSA_LIB);
  2160. return(ret);
  2161. }
  2162. if (s->cert->rsa_tmp != NULL)
  2163. RSA_free(s->cert->rsa_tmp);
  2164. s->cert->rsa_tmp = rsa;
  2165. ret = 1;
  2166. }
  2167. break;
  2168. case SSL_CTRL_SET_TMP_RSA_CB:
  2169. {
  2170. SSLerr(SSL_F_SSL3_CTRL, ERR_R_SHOULD_NOT_HAVE_BEEN_CALLED);
  2171. return(ret);
  2172. }
  2173. break;
  2174. #endif
  2175. #ifndef OPENSSL_NO_DH
  2176. case SSL_CTRL_SET_TMP_DH:
  2177. {
  2178. DH *dh = (DH *)parg;
  2179. if (dh == NULL)
  2180. {
  2181. SSLerr(SSL_F_SSL3_CTRL, ERR_R_PASSED_NULL_PARAMETER);
  2182. return(ret);
  2183. }
  2184. if ((dh = DHparams_dup(dh)) == NULL)
  2185. {
  2186. SSLerr(SSL_F_SSL3_CTRL, ERR_R_DH_LIB);
  2187. return(ret);
  2188. }
  2189. if (!(s->options & SSL_OP_SINGLE_DH_USE))
  2190. {
  2191. if (!DH_generate_key(dh))
  2192. {
  2193. DH_free(dh);
  2194. SSLerr(SSL_F_SSL3_CTRL, ERR_R_DH_LIB);
  2195. return(ret);
  2196. }
  2197. }
  2198. if (s->cert->dh_tmp != NULL)
  2199. DH_free(s->cert->dh_tmp);
  2200. s->cert->dh_tmp = dh;
  2201. ret = 1;
  2202. }
  2203. break;
  2204. case SSL_CTRL_SET_TMP_DH_CB:
  2205. {
  2206. SSLerr(SSL_F_SSL3_CTRL, ERR_R_SHOULD_NOT_HAVE_BEEN_CALLED);
  2207. return(ret);
  2208. }
  2209. break;
  2210. #endif
  2211. #ifndef OPENSSL_NO_ECDH
  2212. case SSL_CTRL_SET_TMP_ECDH:
  2213. {
  2214. EC_KEY *ecdh = NULL;
  2215. if (parg == NULL)
  2216. {
  2217. SSLerr(SSL_F_SSL3_CTRL, ERR_R_PASSED_NULL_PARAMETER);
  2218. return(ret);
  2219. }
  2220. if (!EC_KEY_up_ref((EC_KEY *)parg))
  2221. {
  2222. SSLerr(SSL_F_SSL3_CTRL,ERR_R_ECDH_LIB);
  2223. return(ret);
  2224. }
  2225. ecdh = (EC_KEY *)parg;
  2226. if (!(s->options & SSL_OP_SINGLE_ECDH_USE))
  2227. {
  2228. if (!EC_KEY_generate_key(ecdh))
  2229. {
  2230. EC_KEY_free(ecdh);
  2231. SSLerr(SSL_F_SSL3_CTRL,ERR_R_ECDH_LIB);
  2232. return(ret);
  2233. }
  2234. }
  2235. if (s->cert->ecdh_tmp != NULL)
  2236. EC_KEY_free(s->cert->ecdh_tmp);
  2237. s->cert->ecdh_tmp = ecdh;
  2238. ret = 1;
  2239. }
  2240. break;
  2241. case SSL_CTRL_SET_TMP_ECDH_CB:
  2242. {
  2243. SSLerr(SSL_F_SSL3_CTRL, ERR_R_SHOULD_NOT_HAVE_BEEN_CALLED);
  2244. return(ret);
  2245. }
  2246. break;
  2247. #endif /* !OPENSSL_NO_ECDH */
  2248. #ifndef OPENSSL_NO_TLSEXT
  2249. case SSL_CTRL_SET_TLSEXT_HOSTNAME:
  2250. if (larg == TLSEXT_NAMETYPE_host_name)
  2251. {
  2252. if (s->tlsext_hostname != NULL)
  2253. OPENSSL_free(s->tlsext_hostname);
  2254. s->tlsext_hostname = NULL;
  2255. ret = 1;
  2256. if (parg == NULL)
  2257. break;
  2258. if (strlen((char *)parg) > TLSEXT_MAXLEN_host_name)
  2259. {
  2260. SSLerr(SSL_F_SSL3_CTRL, SSL_R_SSL3_EXT_INVALID_SERVERNAME);
  2261. return 0;
  2262. }
  2263. if ((s->tlsext_hostname = BUF_strdup((char *)parg)) == NULL)
  2264. {
  2265. SSLerr(SSL_F_SSL3_CTRL, ERR_R_INTERNAL_ERROR);
  2266. return 0;
  2267. }
  2268. }
  2269. else
  2270. {
  2271. SSLerr(SSL_F_SSL3_CTRL, SSL_R_SSL3_EXT_INVALID_SERVERNAME_TYPE);
  2272. return 0;
  2273. }
  2274. break;
  2275. case SSL_CTRL_SET_TLSEXT_DEBUG_ARG:
  2276. s->tlsext_debug_arg=parg;
  2277. ret = 1;
  2278. break;
  2279. #ifdef TLSEXT_TYPE_opaque_prf_input
  2280. case SSL_CTRL_SET_TLSEXT_OPAQUE_PRF_INPUT:
  2281. if (larg > 12288) /* actual internal limit is 2^16 for the complete hello message
  2282. * (including the cert chain and everything) */
  2283. {
  2284. SSLerr(SSL_F_SSL3_CTRL, SSL_R_OPAQUE_PRF_INPUT_TOO_LONG);
  2285. break;
  2286. }
  2287. if (s->tlsext_opaque_prf_input != NULL)
  2288. OPENSSL_free(s->tlsext_opaque_prf_input);
  2289. if ((size_t)larg == 0)
  2290. s->tlsext_opaque_prf_input = OPENSSL_malloc(1); /* dummy byte just to get non-NULL */
  2291. else
  2292. s->tlsext_opaque_prf_input = BUF_memdup(parg, (size_t)larg);
  2293. if (s->tlsext_opaque_prf_input != NULL)
  2294. {
  2295. s->tlsext_opaque_prf_input_len = (size_t)larg;
  2296. ret = 1;
  2297. }
  2298. else
  2299. s->tlsext_opaque_prf_input_len = 0;
  2300. break;
  2301. #endif
  2302. case SSL_CTRL_SET_TLSEXT_STATUS_REQ_TYPE:
  2303. s->tlsext_status_type=larg;
  2304. ret = 1;
  2305. break;
  2306. case SSL_CTRL_GET_TLSEXT_STATUS_REQ_EXTS:
  2307. *(STACK_OF(X509_EXTENSION) **)parg = s->tlsext_ocsp_exts;
  2308. ret = 1;
  2309. break;
  2310. case SSL_CTRL_SET_TLSEXT_STATUS_REQ_EXTS:
  2311. s->tlsext_ocsp_exts = parg;
  2312. ret = 1;
  2313. break;
  2314. case SSL_CTRL_GET_TLSEXT_STATUS_REQ_IDS:
  2315. *(STACK_OF(OCSP_RESPID) **)parg = s->tlsext_ocsp_ids;
  2316. ret = 1;
  2317. break;
  2318. case SSL_CTRL_SET_TLSEXT_STATUS_REQ_IDS:
  2319. s->tlsext_ocsp_ids = parg;
  2320. ret = 1;
  2321. break;
  2322. case SSL_CTRL_GET_TLSEXT_STATUS_REQ_OCSP_RESP:
  2323. *(unsigned char **)parg = s->tlsext_ocsp_resp;
  2324. return s->tlsext_ocsp_resplen;
  2325. case SSL_CTRL_SET_TLSEXT_STATUS_REQ_OCSP_RESP:
  2326. if (s->tlsext_ocsp_resp)
  2327. OPENSSL_free(s->tlsext_ocsp_resp);
  2328. s->tlsext_ocsp_resp = parg;
  2329. s->tlsext_ocsp_resplen = larg;
  2330. ret = 1;
  2331. break;
  2332. #endif /* !OPENSSL_NO_TLSEXT */
  2333. default:
  2334. break;
  2335. }
  2336. return(ret);
  2337. }
  2338. long ssl3_callback_ctrl(SSL *s, int cmd, void (*fp)(void))
  2339. {
  2340. int ret=0;
  2341. #if !defined(OPENSSL_NO_DSA) || !defined(OPENSSL_NO_RSA)
  2342. if (
  2343. #ifndef OPENSSL_NO_RSA
  2344. cmd == SSL_CTRL_SET_TMP_RSA_CB ||
  2345. #endif
  2346. #ifndef OPENSSL_NO_DSA
  2347. cmd == SSL_CTRL_SET_TMP_DH_CB ||
  2348. #endif
  2349. 0)
  2350. {
  2351. if (!ssl_cert_inst(&s->cert))
  2352. {
  2353. SSLerr(SSL_F_SSL3_CALLBACK_CTRL, ERR_R_MALLOC_FAILURE);
  2354. return(0);
  2355. }
  2356. }
  2357. #endif
  2358. switch (cmd)
  2359. {
  2360. #ifndef OPENSSL_NO_RSA
  2361. case SSL_CTRL_SET_TMP_RSA_CB:
  2362. {
  2363. s->cert->rsa_tmp_cb = (RSA *(*)(SSL *, int, int))fp;
  2364. }
  2365. break;
  2366. #endif
  2367. #ifndef OPENSSL_NO_DH
  2368. case SSL_CTRL_SET_TMP_DH_CB:
  2369. {
  2370. s->cert->dh_tmp_cb = (DH *(*)(SSL *, int, int))fp;
  2371. }
  2372. break;
  2373. #endif
  2374. #ifndef OPENSSL_NO_ECDH
  2375. case SSL_CTRL_SET_TMP_ECDH_CB:
  2376. {
  2377. s->cert->ecdh_tmp_cb = (EC_KEY *(*)(SSL *, int, int))fp;
  2378. }
  2379. break;
  2380. #endif
  2381. #ifndef OPENSSL_NO_TLSEXT
  2382. case SSL_CTRL_SET_TLSEXT_DEBUG_CB:
  2383. s->tlsext_debug_cb=(void (*)(SSL *,int ,int,
  2384. unsigned char *, int, void *))fp;
  2385. break;
  2386. #endif
  2387. default:
  2388. break;
  2389. }
  2390. return(ret);
  2391. }
  2392. long ssl3_ctx_ctrl(SSL_CTX *ctx, int cmd, long larg, void *parg)
  2393. {
  2394. CERT *cert;
  2395. cert=ctx->cert;
  2396. switch (cmd)
  2397. {
  2398. #ifndef OPENSSL_NO_RSA
  2399. case SSL_CTRL_NEED_TMP_RSA:
  2400. if ( (cert->rsa_tmp == NULL) &&
  2401. ((cert->pkeys[SSL_PKEY_RSA_ENC].privatekey == NULL) ||
  2402. (EVP_PKEY_size(cert->pkeys[SSL_PKEY_RSA_ENC].privatekey) > (512/8)))
  2403. )
  2404. return(1);
  2405. else
  2406. return(0);
  2407. /* break; */
  2408. case SSL_CTRL_SET_TMP_RSA:
  2409. {
  2410. RSA *rsa;
  2411. int i;
  2412. rsa=(RSA *)parg;
  2413. i=1;
  2414. if (rsa == NULL)
  2415. i=0;
  2416. else
  2417. {
  2418. if ((rsa=RSAPrivateKey_dup(rsa)) == NULL)
  2419. i=0;
  2420. }
  2421. if (!i)
  2422. {
  2423. SSLerr(SSL_F_SSL3_CTX_CTRL,ERR_R_RSA_LIB);
  2424. return(0);
  2425. }
  2426. else
  2427. {
  2428. if (cert->rsa_tmp != NULL)
  2429. RSA_free(cert->rsa_tmp);
  2430. cert->rsa_tmp=rsa;
  2431. return(1);
  2432. }
  2433. }
  2434. /* break; */
  2435. case SSL_CTRL_SET_TMP_RSA_CB:
  2436. {
  2437. SSLerr(SSL_F_SSL3_CTX_CTRL, ERR_R_SHOULD_NOT_HAVE_BEEN_CALLED);
  2438. return(0);
  2439. }
  2440. break;
  2441. #endif
  2442. #ifndef OPENSSL_NO_DH
  2443. case SSL_CTRL_SET_TMP_DH:
  2444. {
  2445. DH *new=NULL,*dh;
  2446. dh=(DH *)parg;
  2447. if ((new=DHparams_dup(dh)) == NULL)
  2448. {
  2449. SSLerr(SSL_F_SSL3_CTX_CTRL,ERR_R_DH_LIB);
  2450. return 0;
  2451. }
  2452. if (!(ctx->options & SSL_OP_SINGLE_DH_USE))
  2453. {
  2454. if (!DH_generate_key(new))
  2455. {
  2456. SSLerr(SSL_F_SSL3_CTX_CTRL,ERR_R_DH_LIB);
  2457. DH_free(new);
  2458. return 0;
  2459. }
  2460. }
  2461. if (cert->dh_tmp != NULL)
  2462. DH_free(cert->dh_tmp);
  2463. cert->dh_tmp=new;
  2464. return 1;
  2465. }
  2466. /*break; */
  2467. case SSL_CTRL_SET_TMP_DH_CB:
  2468. {
  2469. SSLerr(SSL_F_SSL3_CTX_CTRL, ERR_R_SHOULD_NOT_HAVE_BEEN_CALLED);
  2470. return(0);
  2471. }
  2472. break;
  2473. #endif
  2474. #ifndef OPENSSL_NO_ECDH
  2475. case SSL_CTRL_SET_TMP_ECDH:
  2476. {
  2477. EC_KEY *ecdh = NULL;
  2478. if (parg == NULL)
  2479. {
  2480. SSLerr(SSL_F_SSL3_CTX_CTRL,ERR_R_ECDH_LIB);
  2481. return 0;
  2482. }
  2483. ecdh = EC_KEY_dup((EC_KEY *)parg);
  2484. if (ecdh == NULL)
  2485. {
  2486. SSLerr(SSL_F_SSL3_CTX_CTRL,ERR_R_EC_LIB);
  2487. return 0;
  2488. }
  2489. if (!(ctx->options & SSL_OP_SINGLE_ECDH_USE))
  2490. {
  2491. if (!EC_KEY_generate_key(ecdh))
  2492. {
  2493. EC_KEY_free(ecdh);
  2494. SSLerr(SSL_F_SSL3_CTX_CTRL,ERR_R_ECDH_LIB);
  2495. return 0;
  2496. }
  2497. }
  2498. if (cert->ecdh_tmp != NULL)
  2499. {
  2500. EC_KEY_free(cert->ecdh_tmp);
  2501. }
  2502. cert->ecdh_tmp = ecdh;
  2503. return 1;
  2504. }
  2505. /* break; */
  2506. case SSL_CTRL_SET_TMP_ECDH_CB:
  2507. {
  2508. SSLerr(SSL_F_SSL3_CTX_CTRL, ERR_R_SHOULD_NOT_HAVE_BEEN_CALLED);
  2509. return(0);
  2510. }
  2511. break;
  2512. #endif /* !OPENSSL_NO_ECDH */
  2513. #ifndef OPENSSL_NO_TLSEXT
  2514. case SSL_CTRL_SET_TLSEXT_SERVERNAME_ARG:
  2515. ctx->tlsext_servername_arg=parg;
  2516. break;
  2517. case SSL_CTRL_SET_TLSEXT_TICKET_KEYS:
  2518. case SSL_CTRL_GET_TLSEXT_TICKET_KEYS:
  2519. {
  2520. unsigned char *keys = parg;
  2521. if (!keys)
  2522. return 48;
  2523. if (larg != 48)
  2524. {
  2525. SSLerr(SSL_F_SSL3_CTX_CTRL, SSL_R_INVALID_TICKET_KEYS_LENGTH);
  2526. return 0;
  2527. }
  2528. if (cmd == SSL_CTRL_SET_TLSEXT_TICKET_KEYS)
  2529. {
  2530. memcpy(ctx->tlsext_tick_key_name, keys, 16);
  2531. memcpy(ctx->tlsext_tick_hmac_key, keys + 16, 16);
  2532. memcpy(ctx->tlsext_tick_aes_key, keys + 32, 16);
  2533. }
  2534. else
  2535. {
  2536. memcpy(keys, ctx->tlsext_tick_key_name, 16);
  2537. memcpy(keys + 16, ctx->tlsext_tick_hmac_key, 16);
  2538. memcpy(keys + 32, ctx->tlsext_tick_aes_key, 16);
  2539. }
  2540. return 1;
  2541. }
  2542. #ifdef TLSEXT_TYPE_opaque_prf_input
  2543. case SSL_CTRL_SET_TLSEXT_OPAQUE_PRF_INPUT_CB_ARG:
  2544. ctx->tlsext_opaque_prf_input_callback_arg = parg;
  2545. return 1;
  2546. #endif
  2547. case SSL_CTRL_SET_TLSEXT_STATUS_REQ_CB_ARG:
  2548. ctx->tlsext_status_arg=parg;
  2549. return 1;
  2550. break;
  2551. #endif /* !OPENSSL_NO_TLSEXT */
  2552. /* A Thawte special :-) */
  2553. case SSL_CTRL_EXTRA_CHAIN_CERT:
  2554. if (ctx->extra_certs == NULL)
  2555. {
  2556. if ((ctx->extra_certs=sk_X509_new_null()) == NULL)
  2557. return(0);
  2558. }
  2559. sk_X509_push(ctx->extra_certs,(X509 *)parg);
  2560. break;
  2561. default:
  2562. return(0);
  2563. }
  2564. return(1);
  2565. }
  2566. long ssl3_ctx_callback_ctrl(SSL_CTX *ctx, int cmd, void (*fp)(void))
  2567. {
  2568. CERT *cert;
  2569. cert=ctx->cert;
  2570. switch (cmd)
  2571. {
  2572. #ifndef OPENSSL_NO_RSA
  2573. case SSL_CTRL_SET_TMP_RSA_CB:
  2574. {
  2575. cert->rsa_tmp_cb = (RSA *(*)(SSL *, int, int))fp;
  2576. }
  2577. break;
  2578. #endif
  2579. #ifndef OPENSSL_NO_DH
  2580. case SSL_CTRL_SET_TMP_DH_CB:
  2581. {
  2582. cert->dh_tmp_cb = (DH *(*)(SSL *, int, int))fp;
  2583. }
  2584. break;
  2585. #endif
  2586. #ifndef OPENSSL_NO_ECDH
  2587. case SSL_CTRL_SET_TMP_ECDH_CB:
  2588. {
  2589. cert->ecdh_tmp_cb = (EC_KEY *(*)(SSL *, int, int))fp;
  2590. }
  2591. break;
  2592. #endif
  2593. #ifndef OPENSSL_NO_TLSEXT
  2594. case SSL_CTRL_SET_TLSEXT_SERVERNAME_CB:
  2595. ctx->tlsext_servername_callback=(int (*)(SSL *,int *,void *))fp;
  2596. break;
  2597. #ifdef TLSEXT_TYPE_opaque_prf_input
  2598. case SSL_CTRL_SET_TLSEXT_OPAQUE_PRF_INPUT_CB:
  2599. ctx->tlsext_opaque_prf_input_callback = (int (*)(SSL *,void *, size_t, void *))fp;
  2600. break;
  2601. #endif
  2602. case SSL_CTRL_SET_TLSEXT_STATUS_REQ_CB:
  2603. ctx->tlsext_status_cb=(int (*)(SSL *,void *))fp;
  2604. break;
  2605. case SSL_CTRL_SET_TLSEXT_TICKET_KEY_CB:
  2606. ctx->tlsext_ticket_key_cb=(int (*)(SSL *,unsigned char *,
  2607. unsigned char *,
  2608. EVP_CIPHER_CTX *,
  2609. HMAC_CTX *, int))fp;
  2610. break;
  2611. #endif
  2612. default:
  2613. return(0);
  2614. }
  2615. return(1);
  2616. }
  2617. /* This function needs to check if the ciphers required are actually
  2618. * available */
  2619. const SSL_CIPHER *ssl3_get_cipher_by_char(const unsigned char *p)
  2620. {
  2621. SSL_CIPHER c;
  2622. const SSL_CIPHER *cp;
  2623. unsigned long id;
  2624. id=0x03000000L|((unsigned long)p[0]<<8L)|(unsigned long)p[1];
  2625. c.id=id;
  2626. cp = OBJ_bsearch_ssl_cipher_id(&c, ssl3_ciphers, SSL3_NUM_CIPHERS);
  2627. if (cp == NULL || cp->valid == 0)
  2628. return NULL;
  2629. else
  2630. return cp;
  2631. }
  2632. int ssl3_put_cipher_by_char(const SSL_CIPHER *c, unsigned char *p)
  2633. {
  2634. long l;
  2635. if (p != NULL)
  2636. {
  2637. l=c->id;
  2638. if ((l & 0xff000000) != 0x03000000) return(0);
  2639. p[0]=((unsigned char)(l>> 8L))&0xFF;
  2640. p[1]=((unsigned char)(l ))&0xFF;
  2641. }
  2642. return(2);
  2643. }
  2644. SSL_CIPHER *ssl3_choose_cipher(SSL *s, STACK_OF(SSL_CIPHER) *clnt,
  2645. STACK_OF(SSL_CIPHER) *srvr)
  2646. {
  2647. SSL_CIPHER *c,*ret=NULL;
  2648. STACK_OF(SSL_CIPHER) *prio, *allow;
  2649. int i,ii,ok;
  2650. #if !defined(OPENSSL_NO_TLSEXT) && !defined(OPENSSL_NO_EC)
  2651. unsigned int j;
  2652. int ec_ok, ec_nid;
  2653. unsigned char ec_search1 = 0, ec_search2 = 0;
  2654. #endif
  2655. CERT *cert;
  2656. unsigned long alg_k,alg_a,mask_k,mask_a,emask_k,emask_a;
  2657. /* Let's see which ciphers we can support */
  2658. cert=s->cert;
  2659. #if 0
  2660. /* Do not set the compare functions, because this may lead to a
  2661. * reordering by "id". We want to keep the original ordering.
  2662. * We may pay a price in performance during sk_SSL_CIPHER_find(),
  2663. * but would have to pay with the price of sk_SSL_CIPHER_dup().
  2664. */
  2665. sk_SSL_CIPHER_set_cmp_func(srvr, ssl_cipher_ptr_id_cmp);
  2666. sk_SSL_CIPHER_set_cmp_func(clnt, ssl_cipher_ptr_id_cmp);
  2667. #endif
  2668. #ifdef CIPHER_DEBUG
  2669. printf("Server has %d from %p:\n", sk_SSL_CIPHER_num(srvr), (void *)srvr);
  2670. for(i=0 ; i < sk_SSL_CIPHER_num(srvr) ; ++i)
  2671. {
  2672. c=sk_SSL_CIPHER_value(srvr,i);
  2673. printf("%p:%s\n",(void *)c,c->name);
  2674. }
  2675. printf("Client sent %d from %p:\n", sk_SSL_CIPHER_num(clnt), (void *)clnt);
  2676. for(i=0 ; i < sk_SSL_CIPHER_num(clnt) ; ++i)
  2677. {
  2678. c=sk_SSL_CIPHER_value(clnt,i);
  2679. printf("%p:%s\n",(void *)c,c->name);
  2680. }
  2681. #endif
  2682. if (s->options & SSL_OP_CIPHER_SERVER_PREFERENCE)
  2683. {
  2684. prio = srvr;
  2685. allow = clnt;
  2686. }
  2687. else
  2688. {
  2689. prio = clnt;
  2690. allow = srvr;
  2691. }
  2692. for (i=0; i<sk_SSL_CIPHER_num(prio); i++)
  2693. {
  2694. c=sk_SSL_CIPHER_value(prio,i);
  2695. ssl_set_cert_masks(cert,c);
  2696. mask_k = cert->mask_k;
  2697. mask_a = cert->mask_a;
  2698. emask_k = cert->export_mask_k;
  2699. emask_a = cert->export_mask_a;
  2700. #ifdef KSSL_DEBUG
  2701. /* printf("ssl3_choose_cipher %d alg= %lx\n", i,c->algorithms);*/
  2702. #endif /* KSSL_DEBUG */
  2703. alg_k=c->algorithm_mkey;
  2704. alg_a=c->algorithm_auth;
  2705. #ifndef OPENSSL_NO_KRB5
  2706. if (alg_k & SSL_kKRB5)
  2707. {
  2708. if ( !kssl_keytab_is_available(s->kssl_ctx) )
  2709. continue;
  2710. }
  2711. #endif /* OPENSSL_NO_KRB5 */
  2712. #ifndef OPENSSL_NO_PSK
  2713. /* with PSK there must be server callback set */
  2714. if ((alg_k & SSL_kPSK) && s->psk_server_callback == NULL)
  2715. continue;
  2716. #endif /* OPENSSL_NO_PSK */
  2717. if (SSL_C_IS_EXPORT(c))
  2718. {
  2719. ok = (alg_k & emask_k) && (alg_a & emask_a);
  2720. #ifdef CIPHER_DEBUG
  2721. printf("%d:[%08lX:%08lX:%08lX:%08lX]%p:%s (export)\n",ok,alg_k,alg_a,emask_k,emask_a,
  2722. (void *)c,c->name);
  2723. #endif
  2724. }
  2725. else
  2726. {
  2727. ok = (alg_k & mask_k) && (alg_a & mask_a);
  2728. #ifdef CIPHER_DEBUG
  2729. printf("%d:[%08lX:%08lX:%08lX:%08lX]%p:%s\n",ok,alg_k,alg_a,mask_k,mask_a,(void *)c,
  2730. c->name);
  2731. #endif
  2732. }
  2733. #ifndef OPENSSL_NO_TLSEXT
  2734. #ifndef OPENSSL_NO_EC
  2735. if (
  2736. /* if we are considering an ECC cipher suite that uses our certificate */
  2737. (alg_a & SSL_aECDSA || alg_a & SSL_aECDH)
  2738. /* and we have an ECC certificate */
  2739. && (s->cert->pkeys[SSL_PKEY_ECC].x509 != NULL)
  2740. /* and the client specified a Supported Point Formats extension */
  2741. && ((s->session->tlsext_ecpointformatlist_length > 0) && (s->session->tlsext_ecpointformatlist != NULL))
  2742. /* and our certificate's point is compressed */
  2743. && (
  2744. (s->cert->pkeys[SSL_PKEY_ECC].x509->cert_info != NULL)
  2745. && (s->cert->pkeys[SSL_PKEY_ECC].x509->cert_info->key != NULL)
  2746. && (s->cert->pkeys[SSL_PKEY_ECC].x509->cert_info->key->public_key != NULL)
  2747. && (s->cert->pkeys[SSL_PKEY_ECC].x509->cert_info->key->public_key->data != NULL)
  2748. && (
  2749. (*(s->cert->pkeys[SSL_PKEY_ECC].x509->cert_info->key->public_key->data) == POINT_CONVERSION_COMPRESSED)
  2750. || (*(s->cert->pkeys[SSL_PKEY_ECC].x509->cert_info->key->public_key->data) == POINT_CONVERSION_COMPRESSED + 1)
  2751. )
  2752. )
  2753. )
  2754. {
  2755. ec_ok = 0;
  2756. /* if our certificate's curve is over a field type that the client does not support
  2757. * then do not allow this cipher suite to be negotiated */
  2758. if (
  2759. (s->cert->pkeys[SSL_PKEY_ECC].privatekey->pkey.ec != NULL)
  2760. && (s->cert->pkeys[SSL_PKEY_ECC].privatekey->pkey.ec->group != NULL)
  2761. && (s->cert->pkeys[SSL_PKEY_ECC].privatekey->pkey.ec->group->meth != NULL)
  2762. && (EC_METHOD_get_field_type(s->cert->pkeys[SSL_PKEY_ECC].privatekey->pkey.ec->group->meth) == NID_X9_62_prime_field)
  2763. )
  2764. {
  2765. for (j = 0; j < s->session->tlsext_ecpointformatlist_length; j++)
  2766. {
  2767. if (s->session->tlsext_ecpointformatlist[j] == TLSEXT_ECPOINTFORMAT_ansiX962_compressed_prime)
  2768. {
  2769. ec_ok = 1;
  2770. break;
  2771. }
  2772. }
  2773. }
  2774. else if (EC_METHOD_get_field_type(s->cert->pkeys[SSL_PKEY_ECC].privatekey->pkey.ec->group->meth) == NID_X9_62_characteristic_two_field)
  2775. {
  2776. for (j = 0; j < s->session->tlsext_ecpointformatlist_length; j++)
  2777. {
  2778. if (s->session->tlsext_ecpointformatlist[j] == TLSEXT_ECPOINTFORMAT_ansiX962_compressed_char2)
  2779. {
  2780. ec_ok = 1;
  2781. break;
  2782. }
  2783. }
  2784. }
  2785. ok = ok && ec_ok;
  2786. }
  2787. if (
  2788. /* if we are considering an ECC cipher suite that uses our certificate */
  2789. (alg_a & SSL_aECDSA || alg_a & SSL_aECDH)
  2790. /* and we have an ECC certificate */
  2791. && (s->cert->pkeys[SSL_PKEY_ECC].x509 != NULL)
  2792. /* and the client specified an EllipticCurves extension */
  2793. && ((s->session->tlsext_ellipticcurvelist_length > 0) && (s->session->tlsext_ellipticcurvelist != NULL))
  2794. )
  2795. {
  2796. ec_ok = 0;
  2797. if (
  2798. (s->cert->pkeys[SSL_PKEY_ECC].privatekey->pkey.ec != NULL)
  2799. && (s->cert->pkeys[SSL_PKEY_ECC].privatekey->pkey.ec->group != NULL)
  2800. )
  2801. {
  2802. ec_nid = EC_GROUP_get_curve_name(s->cert->pkeys[SSL_PKEY_ECC].privatekey->pkey.ec->group);
  2803. if ((ec_nid == 0)
  2804. && (s->cert->pkeys[SSL_PKEY_ECC].privatekey->pkey.ec->group->meth != NULL)
  2805. )
  2806. {
  2807. if (EC_METHOD_get_field_type(s->cert->pkeys[SSL_PKEY_ECC].privatekey->pkey.ec->group->meth) == NID_X9_62_prime_field)
  2808. {
  2809. ec_search1 = 0xFF;
  2810. ec_search2 = 0x01;
  2811. }
  2812. else if (EC_METHOD_get_field_type(s->cert->pkeys[SSL_PKEY_ECC].privatekey->pkey.ec->group->meth) == NID_X9_62_characteristic_two_field)
  2813. {
  2814. ec_search1 = 0xFF;
  2815. ec_search2 = 0x02;
  2816. }
  2817. }
  2818. else
  2819. {
  2820. ec_search1 = 0x00;
  2821. ec_search2 = tls1_ec_nid2curve_id(ec_nid);
  2822. }
  2823. if ((ec_search1 != 0) || (ec_search2 != 0))
  2824. {
  2825. for (j = 0; j < s->session->tlsext_ellipticcurvelist_length / 2; j++)
  2826. {
  2827. if ((s->session->tlsext_ellipticcurvelist[2*j] == ec_search1) && (s->session->tlsext_ellipticcurvelist[2*j+1] == ec_search2))
  2828. {
  2829. ec_ok = 1;
  2830. break;
  2831. }
  2832. }
  2833. }
  2834. }
  2835. ok = ok && ec_ok;
  2836. }
  2837. if (
  2838. /* if we are considering an ECC cipher suite that uses an ephemeral EC key */
  2839. (alg_k & SSL_kEECDH)
  2840. /* and we have an ephemeral EC key */
  2841. && (s->cert->ecdh_tmp != NULL)
  2842. /* and the client specified an EllipticCurves extension */
  2843. && ((s->session->tlsext_ellipticcurvelist_length > 0) && (s->session->tlsext_ellipticcurvelist != NULL))
  2844. )
  2845. {
  2846. ec_ok = 0;
  2847. if (s->cert->ecdh_tmp->group != NULL)
  2848. {
  2849. ec_nid = EC_GROUP_get_curve_name(s->cert->ecdh_tmp->group);
  2850. if ((ec_nid == 0)
  2851. && (s->cert->ecdh_tmp->group->meth != NULL)
  2852. )
  2853. {
  2854. if (EC_METHOD_get_field_type(s->cert->ecdh_tmp->group->meth) == NID_X9_62_prime_field)
  2855. {
  2856. ec_search1 = 0xFF;
  2857. ec_search2 = 0x01;
  2858. }
  2859. else if (EC_METHOD_get_field_type(s->cert->ecdh_tmp->group->meth) == NID_X9_62_characteristic_two_field)
  2860. {
  2861. ec_search1 = 0xFF;
  2862. ec_search2 = 0x02;
  2863. }
  2864. }
  2865. else
  2866. {
  2867. ec_search1 = 0x00;
  2868. ec_search2 = tls1_ec_nid2curve_id(ec_nid);
  2869. }
  2870. if ((ec_search1 != 0) || (ec_search2 != 0))
  2871. {
  2872. for (j = 0; j < s->session->tlsext_ellipticcurvelist_length / 2; j++)
  2873. {
  2874. if ((s->session->tlsext_ellipticcurvelist[2*j] == ec_search1) && (s->session->tlsext_ellipticcurvelist[2*j+1] == ec_search2))
  2875. {
  2876. ec_ok = 1;
  2877. break;
  2878. }
  2879. }
  2880. }
  2881. }
  2882. ok = ok && ec_ok;
  2883. }
  2884. #endif /* OPENSSL_NO_EC */
  2885. #endif /* OPENSSL_NO_TLSEXT */
  2886. if (!ok) continue;
  2887. ii=sk_SSL_CIPHER_find(allow,c);
  2888. if (ii >= 0)
  2889. {
  2890. ret=sk_SSL_CIPHER_value(allow,ii);
  2891. break;
  2892. }
  2893. }
  2894. return(ret);
  2895. }
  2896. int ssl3_get_req_cert_type(SSL *s, unsigned char *p)
  2897. {
  2898. int ret=0;
  2899. unsigned long alg_k;
  2900. alg_k = s->s3->tmp.new_cipher->algorithm_mkey;
  2901. #ifndef OPENSSL_NO_GOST
  2902. if (s->version >= TLS1_VERSION)
  2903. {
  2904. if (alg_k & SSL_kGOST)
  2905. {
  2906. p[ret++]=TLS_CT_GOST94_SIGN;
  2907. p[ret++]=TLS_CT_GOST01_SIGN;
  2908. return(ret);
  2909. }
  2910. }
  2911. #endif
  2912. #ifndef OPENSSL_NO_DH
  2913. if (alg_k & (SSL_kDHr|SSL_kEDH))
  2914. {
  2915. # ifndef OPENSSL_NO_RSA
  2916. p[ret++]=SSL3_CT_RSA_FIXED_DH;
  2917. # endif
  2918. # ifndef OPENSSL_NO_DSA
  2919. p[ret++]=SSL3_CT_DSS_FIXED_DH;
  2920. # endif
  2921. }
  2922. if ((s->version == SSL3_VERSION) &&
  2923. (alg_k & (SSL_kEDH|SSL_kDHd|SSL_kDHr)))
  2924. {
  2925. # ifndef OPENSSL_NO_RSA
  2926. p[ret++]=SSL3_CT_RSA_EPHEMERAL_DH;
  2927. # endif
  2928. # ifndef OPENSSL_NO_DSA
  2929. p[ret++]=SSL3_CT_DSS_EPHEMERAL_DH;
  2930. # endif
  2931. }
  2932. #endif /* !OPENSSL_NO_DH */
  2933. #ifndef OPENSSL_NO_RSA
  2934. p[ret++]=SSL3_CT_RSA_SIGN;
  2935. #endif
  2936. #ifndef OPENSSL_NO_DSA
  2937. p[ret++]=SSL3_CT_DSS_SIGN;
  2938. #endif
  2939. #ifndef OPENSSL_NO_ECDH
  2940. if ((alg_k & (SSL_kECDHr|SSL_kECDHe)) && (s->version >= TLS1_VERSION))
  2941. {
  2942. p[ret++]=TLS_CT_RSA_FIXED_ECDH;
  2943. p[ret++]=TLS_CT_ECDSA_FIXED_ECDH;
  2944. }
  2945. #endif
  2946. #ifndef OPENSSL_NO_ECDSA
  2947. /* ECDSA certs can be used with RSA cipher suites as well
  2948. * so we don't need to check for SSL_kECDH or SSL_kEECDH
  2949. */
  2950. if (s->version >= TLS1_VERSION)
  2951. {
  2952. p[ret++]=TLS_CT_ECDSA_SIGN;
  2953. }
  2954. #endif
  2955. return(ret);
  2956. }
  2957. int ssl3_shutdown(SSL *s)
  2958. {
  2959. int ret;
  2960. /* Don't do anything much if we have not done the handshake or
  2961. * we don't want to send messages :-) */
  2962. if ((s->quiet_shutdown) || (s->state == SSL_ST_BEFORE))
  2963. {
  2964. s->shutdown=(SSL_SENT_SHUTDOWN|SSL_RECEIVED_SHUTDOWN);
  2965. return(1);
  2966. }
  2967. if (!(s->shutdown & SSL_SENT_SHUTDOWN))
  2968. {
  2969. s->shutdown|=SSL_SENT_SHUTDOWN;
  2970. #if 1
  2971. ssl3_send_alert(s,SSL3_AL_WARNING,SSL_AD_CLOSE_NOTIFY);
  2972. #endif
  2973. /* our shutdown alert has been sent now, and if it still needs
  2974. * to be written, s->s3->alert_dispatch will be true */
  2975. if (s->s3->alert_dispatch)
  2976. return(-1); /* return WANT_WRITE */
  2977. }
  2978. else if (s->s3->alert_dispatch)
  2979. {
  2980. /* resend it if not sent */
  2981. #if 1
  2982. ret=s->method->ssl_dispatch_alert(s);
  2983. if(ret == -1)
  2984. {
  2985. /* we only get to return -1 here the 2nd/Nth
  2986. * invocation, we must have already signalled
  2987. * return 0 upon a previous invoation,
  2988. * return WANT_WRITE */
  2989. return(ret);
  2990. }
  2991. #endif
  2992. }
  2993. else if (!(s->shutdown & SSL_RECEIVED_SHUTDOWN))
  2994. {
  2995. /* If we are waiting for a close from our peer, we are closed */
  2996. s->method->ssl_read_bytes(s,0,NULL,0,0);
  2997. if(!(s->shutdown & SSL_RECEIVED_SHUTDOWN))
  2998. {
  2999. return(-1); /* return WANT_READ */
  3000. }
  3001. }
  3002. if ((s->shutdown == (SSL_SENT_SHUTDOWN|SSL_RECEIVED_SHUTDOWN)) &&
  3003. !s->s3->alert_dispatch)
  3004. return(1);
  3005. else
  3006. return(0);
  3007. }
  3008. int ssl3_write(SSL *s, const void *buf, int len)
  3009. {
  3010. int ret,n;
  3011. #if 0
  3012. if (s->shutdown & SSL_SEND_SHUTDOWN)
  3013. {
  3014. s->rwstate=SSL_NOTHING;
  3015. return(0);
  3016. }
  3017. #endif
  3018. clear_sys_error();
  3019. if (s->s3->renegotiate) ssl3_renegotiate_check(s);
  3020. /* This is an experimental flag that sends the
  3021. * last handshake message in the same packet as the first
  3022. * use data - used to see if it helps the TCP protocol during
  3023. * session-id reuse */
  3024. /* The second test is because the buffer may have been removed */
  3025. if ((s->s3->flags & SSL3_FLAGS_POP_BUFFER) && (s->wbio == s->bbio))
  3026. {
  3027. /* First time through, we write into the buffer */
  3028. if (s->s3->delay_buf_pop_ret == 0)
  3029. {
  3030. ret=ssl3_write_bytes(s,SSL3_RT_APPLICATION_DATA,
  3031. buf,len);
  3032. if (ret <= 0) return(ret);
  3033. s->s3->delay_buf_pop_ret=ret;
  3034. }
  3035. s->rwstate=SSL_WRITING;
  3036. n=BIO_flush(s->wbio);
  3037. if (n <= 0) return(n);
  3038. s->rwstate=SSL_NOTHING;
  3039. /* We have flushed the buffer, so remove it */
  3040. ssl_free_wbio_buffer(s);
  3041. s->s3->flags&= ~SSL3_FLAGS_POP_BUFFER;
  3042. ret=s->s3->delay_buf_pop_ret;
  3043. s->s3->delay_buf_pop_ret=0;
  3044. }
  3045. else
  3046. {
  3047. ret=s->method->ssl_write_bytes(s,SSL3_RT_APPLICATION_DATA,
  3048. buf,len);
  3049. if (ret <= 0) return(ret);
  3050. }
  3051. return(ret);
  3052. }
  3053. static int ssl3_read_internal(SSL *s, void *buf, int len, int peek)
  3054. {
  3055. int ret;
  3056. clear_sys_error();
  3057. if (s->s3->renegotiate) ssl3_renegotiate_check(s);
  3058. s->s3->in_read_app_data=1;
  3059. ret=s->method->ssl_read_bytes(s,SSL3_RT_APPLICATION_DATA,buf,len,peek);
  3060. if ((ret == -1) && (s->s3->in_read_app_data == 2))
  3061. {
  3062. /* ssl3_read_bytes decided to call s->handshake_func, which
  3063. * called ssl3_read_bytes to read handshake data.
  3064. * However, ssl3_read_bytes actually found application data
  3065. * and thinks that application data makes sense here; so disable
  3066. * handshake processing and try to read application data again. */
  3067. s->in_handshake++;
  3068. ret=s->method->ssl_read_bytes(s,SSL3_RT_APPLICATION_DATA,buf,len,peek);
  3069. s->in_handshake--;
  3070. }
  3071. else
  3072. s->s3->in_read_app_data=0;
  3073. return(ret);
  3074. }
  3075. int ssl3_read(SSL *s, void *buf, int len)
  3076. {
  3077. return ssl3_read_internal(s, buf, len, 0);
  3078. }
  3079. int ssl3_peek(SSL *s, void *buf, int len)
  3080. {
  3081. return ssl3_read_internal(s, buf, len, 1);
  3082. }
  3083. int ssl3_renegotiate(SSL *s)
  3084. {
  3085. if (s->handshake_func == NULL)
  3086. return(1);
  3087. if (s->s3->flags & SSL3_FLAGS_NO_RENEGOTIATE_CIPHERS)
  3088. return(0);
  3089. s->s3->renegotiate=1;
  3090. return(1);
  3091. }
  3092. int ssl3_renegotiate_check(SSL *s)
  3093. {
  3094. int ret=0;
  3095. if (s->s3->renegotiate)
  3096. {
  3097. if ( (s->s3->rbuf.left == 0) &&
  3098. (s->s3->wbuf.left == 0) &&
  3099. !SSL_in_init(s))
  3100. {
  3101. /*
  3102. if we are the server, and we have sent a 'RENEGOTIATE' message, we
  3103. need to go to SSL_ST_ACCEPT.
  3104. */
  3105. /* SSL_ST_ACCEPT */
  3106. s->state=SSL_ST_RENEGOTIATE;
  3107. s->s3->renegotiate=0;
  3108. s->s3->num_renegotiations++;
  3109. s->s3->total_renegotiations++;
  3110. ret=1;
  3111. }
  3112. }
  3113. return(ret);
  3114. }