s3_lib.c 65 KB

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