Package: freeradius / 3.0.12+dfsg-5+deb9u1

openssl-1.1.diff Patch series | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
Description: largely backported from FreeRADIUS 4.x, rest forwarded
Author: Michael Stapelberg <stapelberg@debian.org>
Forwarded: not-needed
Last-Update: 2016-11-04

---

Index: freeradius-new/src/main/tls.c
===================================================================
--- freeradius-new.orig/src/main/tls.c
+++ freeradius-new/src/main/tls.c
@@ -1910,7 +1910,9 @@ int cbtls_verify(int ok, X509_STORE_CTX
 	char		cn_str[1024];
 	char		buf[64];
 	X509		*client_cert;
+#if OPENSSL_VERSION_NUMBER < 0x10100000L
 	X509_CINF	*client_inf;
+#endif
 	STACK_OF(X509_EXTENSION) *ext_list;
 	SSL		*ssl;
 	int		err, depth, lookup, loc;
@@ -2016,7 +2018,7 @@ int cbtls_verify(int ok, X509_STORE_CTX
 		rdebug_pair(L_DBG_LVL_2, request, vp, NULL);
 	}
 
-	X509_NAME_oneline(X509_get_issuer_name(ctx->current_cert), issuer,
+	X509_NAME_oneline(X509_get_issuer_name(client_cert), issuer,
 			  sizeof(issuer));
 	issuer[sizeof(issuer) - 1] = '\0';
 	if (certs && identity && (lookup <= 1) && issuer[0]) {
@@ -2109,8 +2111,12 @@ int cbtls_verify(int ok, X509_STORE_CTX
 	}
 
 	if (lookup == 0) {
+#if OPENSSL_VERSION_NUMBER >= 0x10100000L
+		ext_list = X509_get0_extensions(client_cert);
+#else
 		client_inf = client_cert->cert_info;
 		ext_list = client_inf->extensions;
+#endif
 	} else {
 		ext_list = NULL;
 	}
@@ -2170,7 +2176,7 @@ int cbtls_verify(int ok, X509_STORE_CTX
 
 	REXDENT();
 
-	switch (ctx->error) {
+	switch (X509_STORE_CTX_get_error(ctx)) {
 	case X509_V_ERR_UNABLE_TO_GET_ISSUER_CERT:
 		RERROR("issuer=%s", issuer);
 		break;
Index: freeradius-new/src/modules/rlm_otp/otp_radstate.c
===================================================================
--- freeradius-new.orig/src/modules/rlm_otp/otp_radstate.c
+++ freeradius-new/src/modules/rlm_otp/otp_radstate.c
@@ -110,7 +110,7 @@ size_t otp_gen_state(char state[OTP_MAX_
 		     size_t clen,
 		     int32_t flags, int32_t when, uint8_t const key[16])
 {
-	HMAC_CTX hmac_ctx;
+	HMAC_CTX *hmac_ctx;
 	uint8_t hmac[MD5_DIGEST_LENGTH];
 	char *p;
 
@@ -120,12 +120,13 @@ size_t otp_gen_state(char state[OTP_MAX_
 	 *	having to collect the data to be signed into one
 	 *	contiguous piece.
 	 */
-	HMAC_Init(&hmac_ctx, key, sizeof(key[0]) * 16, EVP_md5());
-	HMAC_Update(&hmac_ctx, (uint8_t const *) challenge, clen);
-	HMAC_Update(&hmac_ctx, (uint8_t *) &flags, 4);
-	HMAC_Update(&hmac_ctx, (uint8_t *) &when, 4);
-	HMAC_Final(&hmac_ctx, hmac, NULL);
-	HMAC_cleanup(&hmac_ctx);
+	hmac_ctx = HMAC_CTX_new();
+	HMAC_Init_ex(hmac_ctx, key, sizeof(key[0]) * 16, EVP_md5(), NULL);
+	HMAC_Update(hmac_ctx, (uint8_t const *) challenge, clen);
+	HMAC_Update(hmac_ctx, (uint8_t *) &flags, 4);
+	HMAC_Update(hmac_ctx, (uint8_t *) &when, 4);
+	HMAC_Final(hmac_ctx, hmac, NULL);
+	HMAC_CTX_free(hmac_ctx);
 
 	/*
 	 *	Generate the state.
Index: freeradius-new/src/modules/rlm_wimax/rlm_wimax.c
===================================================================
--- freeradius-new.orig/src/modules/rlm_wimax/rlm_wimax.c
+++ freeradius-new/src/modules/rlm_wimax/rlm_wimax.c
@@ -122,7 +122,7 @@ static rlm_rcode_t CC_HINT(nonnull) mod_
 	rlm_wimax_t *inst = instance;
 	VALUE_PAIR *msk, *emsk, *vp;
 	VALUE_PAIR *mn_nai, *ip, *fa_rk;
-	HMAC_CTX hmac;
+	HMAC_CTX *hmac;
 	unsigned int rk1_len, rk2_len, rk_len;
 	uint32_t mip_spi;
 	uint8_t usage_data[24];
@@ -161,20 +161,20 @@ static rlm_rcode_t CC_HINT(nonnull) mod_
 	/*
 	 *	MIP-RK-1 = HMAC-SSHA256(EMSK, usage-data | 0x01)
 	 */
-	HMAC_CTX_init(&hmac);
-	HMAC_Init_ex(&hmac, emsk->vp_octets, emsk->vp_length, EVP_sha256(), NULL);
+	hmac = HMAC_CTX_new();
+	HMAC_Init_ex(hmac, emsk->vp_octets, emsk->vp_length, EVP_sha256(), NULL);
 
-	HMAC_Update(&hmac, &usage_data[0], sizeof(usage_data));
-	HMAC_Final(&hmac, &mip_rk_1[0], &rk1_len);
+	HMAC_Update(hmac, &usage_data[0], sizeof(usage_data));
+	HMAC_Final(hmac, &mip_rk_1[0], &rk1_len);
 
 	/*
 	 *	MIP-RK-2 = HMAC-SSHA256(EMSK, MIP-RK-1 | usage-data | 0x01)
 	 */
-	HMAC_Init_ex(&hmac, emsk->vp_octets, emsk->vp_length, EVP_sha256(), NULL);
+	HMAC_Init_ex(hmac, emsk->vp_octets, emsk->vp_length, EVP_sha256(), NULL);
 
-	HMAC_Update(&hmac, (uint8_t const *) &mip_rk_1, rk1_len);
-	HMAC_Update(&hmac, &usage_data[0], sizeof(usage_data));
-	HMAC_Final(&hmac, &mip_rk_2[0], &rk2_len);
+	HMAC_Update(hmac, (uint8_t const *) &mip_rk_1, rk1_len);
+	HMAC_Update(hmac, &usage_data[0], sizeof(usage_data));
+	HMAC_Final(hmac, &mip_rk_2[0], &rk2_len);
 
 	memcpy(mip_rk, mip_rk_1, rk1_len);
 	memcpy(mip_rk + rk1_len, mip_rk_2, rk2_len);
@@ -183,10 +183,10 @@ static rlm_rcode_t CC_HINT(nonnull) mod_
 	/*
 	 *	MIP-SPI = HMAC-SSHA256(MIP-RK, "SPI CMIP PMIP");
 	 */
-	HMAC_Init_ex(&hmac, mip_rk, rk_len, EVP_sha256(), NULL);
+	HMAC_Init_ex(hmac, mip_rk, rk_len, EVP_sha256(), NULL);
 
-	HMAC_Update(&hmac, (uint8_t const *) "SPI CMIP PMIP", 12);
-	HMAC_Final(&hmac, &mip_rk_1[0], &rk1_len);
+	HMAC_Update(hmac, (uint8_t const *) "SPI CMIP PMIP", 12);
+	HMAC_Final(hmac, &mip_rk_1[0], &rk1_len);
 
 	/*
 	 *	Take the 4 most significant octets.
@@ -246,12 +246,12 @@ static rlm_rcode_t CC_HINT(nonnull) mod_
 		 *	MN-HA-PMIP4 =
 		 *	   H(MIP-RK, "PMIP4 MN HA" | HA-IPv4 | MN-NAI);
 		 */
-		HMAC_Init_ex(&hmac, mip_rk, rk_len, EVP_sha1(), NULL);
+		HMAC_Init_ex(hmac, mip_rk, rk_len, EVP_sha1(), NULL);
 
-		HMAC_Update(&hmac, (uint8_t const *) "PMIP4 MN HA", 11);
-		HMAC_Update(&hmac, (uint8_t const *) &ip->vp_ipaddr, 4);
-		HMAC_Update(&hmac, (uint8_t const *) &mn_nai->vp_strvalue, mn_nai->vp_length);
-		HMAC_Final(&hmac, &mip_rk_1[0], &rk1_len);
+		HMAC_Update(hmac, (uint8_t const *) "PMIP4 MN HA", 11);
+		HMAC_Update(hmac, (uint8_t const *) &ip->vp_ipaddr, 4);
+		HMAC_Update(hmac, (uint8_t const *) &mn_nai->vp_strvalue, mn_nai->vp_length);
+		HMAC_Final(hmac, &mip_rk_1[0], &rk1_len);
 
 		/*
 		 *	Put MN-HA-PMIP4 into WiMAX-MN-hHA-MIP4-Key
@@ -296,12 +296,12 @@ static rlm_rcode_t CC_HINT(nonnull) mod_
 		 *	MN-HA-CMIP4 =
 		 *	   H(MIP-RK, "CMIP4 MN HA" | HA-IPv4 | MN-NAI);
 		 */
-		HMAC_Init_ex(&hmac, mip_rk, rk_len, EVP_sha1(), NULL);
+		HMAC_Init_ex(hmac, mip_rk, rk_len, EVP_sha1(), NULL);
 
-		HMAC_Update(&hmac, (uint8_t const *) "CMIP4 MN HA", 11);
-		HMAC_Update(&hmac, (uint8_t const *) &ip->vp_ipaddr, 4);
-		HMAC_Update(&hmac, (uint8_t const *) &mn_nai->vp_strvalue, mn_nai->vp_length);
-		HMAC_Final(&hmac, &mip_rk_1[0], &rk1_len);
+		HMAC_Update(hmac, (uint8_t const *) "CMIP4 MN HA", 11);
+		HMAC_Update(hmac, (uint8_t const *) &ip->vp_ipaddr, 4);
+		HMAC_Update(hmac, (uint8_t const *) &mn_nai->vp_strvalue, mn_nai->vp_length);
+		HMAC_Final(hmac, &mip_rk_1[0], &rk1_len);
 
 		/*
 		 *	Put MN-HA-CMIP4 into WiMAX-MN-hHA-MIP4-Key
@@ -346,12 +346,12 @@ static rlm_rcode_t CC_HINT(nonnull) mod_
 		 *	MN-HA-CMIP6 =
 		 *	   H(MIP-RK, "CMIP6 MN HA" | HA-IPv6 | MN-NAI);
 		 */
-		HMAC_Init_ex(&hmac, mip_rk, rk_len, EVP_sha1(), NULL);
+		HMAC_Init_ex(hmac, mip_rk, rk_len, EVP_sha1(), NULL);
 
-		HMAC_Update(&hmac, (uint8_t const *) "CMIP6 MN HA", 11);
-		HMAC_Update(&hmac, (uint8_t const *) &ip->vp_ipv6addr, 16);
-		HMAC_Update(&hmac, (uint8_t const *) &mn_nai->vp_strvalue, mn_nai->vp_length);
-		HMAC_Final(&hmac, &mip_rk_1[0], &rk1_len);
+		HMAC_Update(hmac, (uint8_t const *) "CMIP6 MN HA", 11);
+		HMAC_Update(hmac, (uint8_t const *) &ip->vp_ipv6addr, 16);
+		HMAC_Update(hmac, (uint8_t const *) &mn_nai->vp_strvalue, mn_nai->vp_length);
+		HMAC_Final(hmac, &mip_rk_1[0], &rk1_len);
 
 		/*
 		 *	Put MN-HA-CMIP6 into WiMAX-MN-hHA-MIP6-Key
@@ -393,11 +393,11 @@ static rlm_rcode_t CC_HINT(nonnull) mod_
 	 */
 	fa_rk = fr_pair_find_by_num(request->reply->vps, 14, VENDORPEC_WIMAX, TAG_ANY);
 	if (fa_rk && (fa_rk->vp_length <= 1)) {
-		HMAC_Init_ex(&hmac, mip_rk, rk_len, EVP_sha1(), NULL);
+		HMAC_Init_ex(hmac, mip_rk, rk_len, EVP_sha1(), NULL);
 
-		HMAC_Update(&hmac, (uint8_t const *) "FA-RK", 5);
+		HMAC_Update(hmac, (uint8_t const *) "FA-RK", 5);
 
-		HMAC_Final(&hmac, &mip_rk_1[0], &rk1_len);
+		HMAC_Final(hmac, &mip_rk_1[0], &rk1_len);
 
 		fr_pair_value_memcpy(fa_rk, &mip_rk_1[0], rk1_len);
 	}
@@ -451,7 +451,7 @@ static rlm_rcode_t CC_HINT(nonnull) mod_
 	/*
 	 *	Wipe the context of all sensitive information.
 	 */
-	HMAC_CTX_cleanup(&hmac);
+	HMAC_CTX_free(hmac);
 
 	return RLM_MODULE_UPDATED;
 }
Index: freeradius-new/src/modules/rlm_eap/types/rlm_eap_pwd/configure
===================================================================
--- freeradius-new.orig/src/modules/rlm_eap/types/rlm_eap_pwd/configure
+++ freeradius-new/src/modules/rlm_eap/types/rlm_eap_pwd/configure
@@ -1,5 +1,5 @@
 #! /bin/sh
-# From configure.ac Revision.
+# From src/modules/rlm_eap/types/rlm_eap_pwd/configure.ac Revision.
 # Guess values for system-dependent variables and create Makefiles.
 # Generated by GNU Autoconf 2.69.
 #
@@ -614,6 +614,7 @@ infodir
 docdir
 oldincludedir
 includedir
+runstatedir
 localstatedir
 sharedstatedir
 sysconfdir
@@ -685,6 +686,7 @@ datadir='${datarootdir}'
 sysconfdir='${prefix}/etc'
 sharedstatedir='${prefix}/com'
 localstatedir='${prefix}/var'
+runstatedir='${localstatedir}/run'
 includedir='${prefix}/include'
 oldincludedir='/usr/include'
 docdir='${datarootdir}/doc/${PACKAGE}'
@@ -937,6 +939,15 @@ do
   | -silent | --silent | --silen | --sile | --sil)
     silent=yes ;;
 
+  -runstatedir | --runstatedir | --runstatedi | --runstated \
+  | --runstate | --runstat | --runsta | --runst | --runs \
+  | --run | --ru | --r)
+    ac_prev=runstatedir ;;
+  -runstatedir=* | --runstatedir=* | --runstatedi=* | --runstated=* \
+  | --runstate=* | --runstat=* | --runsta=* | --runst=* | --runs=* \
+  | --run=* | --ru=* | --r=*)
+    runstatedir=$ac_optarg ;;
+
   -sbindir | --sbindir | --sbindi | --sbind | --sbin | --sbi | --sb)
     ac_prev=sbindir ;;
   -sbindir=* | --sbindir=* | --sbindi=* | --sbind=* | --sbin=* \
@@ -1074,7 +1085,7 @@ fi
 for ac_var in	exec_prefix prefix bindir sbindir libexecdir datarootdir \
 		datadir sysconfdir sharedstatedir localstatedir includedir \
 		oldincludedir docdir infodir htmldir dvidir pdfdir psdir \
-		libdir localedir mandir
+		libdir localedir mandir runstatedir
 do
   eval ac_val=\$$ac_var
   # Remove trailing slashes.
@@ -1227,6 +1238,7 @@ Fine tuning of the installation director
   --sysconfdir=DIR        read-only single-machine data [PREFIX/etc]
   --sharedstatedir=DIR    modifiable architecture-independent data [PREFIX/com]
   --localstatedir=DIR     modifiable single-machine data [PREFIX/var]
+  --runstatedir=DIR       modifiable per-process data [LOCALSTATEDIR/run]
   --libdir=DIR            object code libraries [EPREFIX/lib]
   --includedir=DIR        C header files [PREFIX/include]
   --oldincludedir=DIR     C header files for non-gcc [/usr/include]
@@ -2917,7 +2929,7 @@ smart_prefix=
 
 
 sm_lib_safe=`echo "crypto" | sed 'y%./+-%__p_%'`
-sm_func_safe=`echo "EVP_cleanup" | sed 'y%./+-%__p_%'`
+sm_func_safe=`echo "EVP_PKEY_new" | sed 'y%./+-%__p_%'`
 
 old_LIBS="$LIBS"
 old_CPPFLAGS="$CPPFLAGS"
@@ -2927,17 +2939,17 @@ smart_lib_dir=
 
 if test "x$smart_try_dir" != "x"; then
   for try in $smart_try_dir; do
-    { $as_echo "$as_me:${as_lineno-$LINENO}: checking for EVP_cleanup in -lcrypto in $try" >&5
-$as_echo_n "checking for EVP_cleanup in -lcrypto in $try... " >&6; }
+    { $as_echo "$as_me:${as_lineno-$LINENO}: checking for EVP_PKEY_new in -lcrypto in $try" >&5
+$as_echo_n "checking for EVP_PKEY_new in -lcrypto in $try... " >&6; }
     LIBS="-lcrypto $old_LIBS"
     CPPFLAGS="-L$try -Wl,-rpath,$try $old_CPPFLAGS"
     cat confdefs.h - <<_ACEOF >conftest.$ac_ext
 /* end confdefs.h.  */
-extern char EVP_cleanup();
+extern char EVP_PKEY_new();
 int
 main ()
 {
-EVP_cleanup()
+EVP_PKEY_new()
   ;
   return 0;
 }
@@ -2962,16 +2974,16 @@ rm -f core conftest.err conftest.$ac_obj
 fi
 
 if test "x$smart_lib" = "x"; then
-  { $as_echo "$as_me:${as_lineno-$LINENO}: checking for EVP_cleanup in -lcrypto" >&5
-$as_echo_n "checking for EVP_cleanup in -lcrypto... " >&6; }
+  { $as_echo "$as_me:${as_lineno-$LINENO}: checking for EVP_PKEY_new in -lcrypto" >&5
+$as_echo_n "checking for EVP_PKEY_new in -lcrypto... " >&6; }
   LIBS="-lcrypto $old_LIBS"
   cat confdefs.h - <<_ACEOF >conftest.$ac_ext
 /* end confdefs.h.  */
-extern char EVP_cleanup();
+extern char EVP_PKEY_new();
 int
 main ()
 {
-EVP_cleanup()
+EVP_PKEY_new()
   ;
   return 0;
 }
@@ -3048,17 +3060,17 @@ eval "smart_lib_dir=\"\$smart_lib_dir $D
 
 
   for try in $smart_lib_dir /usr/local/lib /opt/lib; do
-    { $as_echo "$as_me:${as_lineno-$LINENO}: checking for EVP_cleanup in -lcrypto in $try" >&5
-$as_echo_n "checking for EVP_cleanup in -lcrypto in $try... " >&6; }
+    { $as_echo "$as_me:${as_lineno-$LINENO}: checking for EVP_PKEY_new in -lcrypto in $try" >&5
+$as_echo_n "checking for EVP_PKEY_new in -lcrypto in $try... " >&6; }
     LIBS="-lcrypto $old_LIBS"
     CPPFLAGS="-L$try -Wl,-rpath,$try $old_CPPFLAGS"
     cat confdefs.h - <<_ACEOF >conftest.$ac_ext
 /* end confdefs.h.  */
-extern char EVP_cleanup();
+extern char EVP_PKEY_new();
 int
 main ()
 {
-EVP_cleanup()
+EVP_PKEY_new()
   ;
   return 0;
 }
@@ -3088,7 +3100,7 @@ if test "x$smart_lib" != "x"; then
   SMART_LIBS="$smart_ldflags $smart_lib $SMART_LIBS"
 fi
 
-        if test "x$ac_cv_lib_crypto_EVP_cleanup" != "xyes"; then
+        if test "x$ac_cv_lib_crypto_EVP_PKEY_new" != "xyes"; then
 	  fail="libssl"
         else
           for ac_func in EVP_sha256
Index: freeradius-new/src/modules/rlm_eap/types/rlm_eap_pwd/configure.ac
===================================================================
--- freeradius-new.orig/src/modules/rlm_eap/types/rlm_eap_pwd/configure.ac
+++ freeradius-new/src/modules/rlm_eap/types/rlm_eap_pwd/configure.ac
@@ -60,8 +60,8 @@ if test x$with_[]modname != xno; then
 	fi
 
 	smart_try_dir=$openssl_lib_dir
-        FR_SMART_CHECK_LIB(crypto, EVP_cleanup)
-        if test "x$ac_cv_lib_crypto_EVP_cleanup" != "xyes"; then
+        FR_SMART_CHECK_LIB(crypto, EVP_PKEY_new)
+        if test "x$ac_cv_lib_crypto_EVP_PKEY_new" != "xyes"; then
 	  fail="libssl"
         else
           AC_CHECK_FUNCS(EVP_sha256)
Index: freeradius-new/src/modules/rlm_eap/types/rlm_eap_pwd/eap_pwd.c
===================================================================
--- freeradius-new.orig/src/modules/rlm_eap/types/rlm_eap_pwd/eap_pwd.c
+++ freeradius-new/src/modules/rlm_eap/types/rlm_eap_pwd/eap_pwd.c
@@ -45,7 +45,7 @@ static void H_Init(HMAC_CTX *ctx)
 	uint8_t allzero[SHA256_DIGEST_LENGTH];
 
 	memset(allzero, 0, SHA256_DIGEST_LENGTH);
-	HMAC_Init(ctx, allzero, SHA256_DIGEST_LENGTH, EVP_sha256());
+	HMAC_Init_ex(ctx, allzero, SHA256_DIGEST_LENGTH, EVP_sha256(), NULL);
 }
 
 static void H_Update(HMAC_CTX *ctx, uint8_t const *data, int len)
@@ -58,39 +58,49 @@ static void H_Final(HMAC_CTX *ctx, uint8
 	unsigned int mdlen = SHA256_DIGEST_LENGTH;
 
 	HMAC_Final(ctx, digest, &mdlen);
+#if OPENSSL_VERSION_NUMBER >= 0x10100000L
+	HMAC_CTX_reset(ctx);
+#else
 	HMAC_CTX_cleanup(ctx);
+#endif
 }
 
 /* a counter-based KDF based on NIST SP800-108 */
 static void eap_pwd_kdf(uint8_t *key, int keylen, char const *label, int labellen, uint8_t *result, int resultbitlen)
 {
-	HMAC_CTX hctx;
+	HMAC_CTX *hctx;
 	uint8_t digest[SHA256_DIGEST_LENGTH];
 	uint16_t i, ctr, L;
 	int resultbytelen, len = 0;
 	unsigned int mdlen = SHA256_DIGEST_LENGTH;
 	uint8_t mask = 0xff;
 
+	hctx = HMAC_CTX_new();
+
 	resultbytelen = (resultbitlen + 7)/8;
 	ctr = 0;
 	L = htons(resultbitlen);
 	while (len < resultbytelen) {
 		ctr++; i = htons(ctr);
-		HMAC_Init(&hctx, key, keylen, EVP_sha256());
+		HMAC_Init_ex(hctx, key, keylen, EVP_sha256(), NULL);
 		if (ctr > 1) {
-			HMAC_Update(&hctx, digest, mdlen);
+			HMAC_Update(hctx, digest, mdlen);
 		}
-		HMAC_Update(&hctx, (uint8_t *) &i, sizeof(uint16_t));
-		HMAC_Update(&hctx, (uint8_t const *)label, labellen);
-		HMAC_Update(&hctx, (uint8_t *) &L, sizeof(uint16_t));
-		HMAC_Final(&hctx, digest, &mdlen);
+		HMAC_Update(hctx, (uint8_t *) &i, sizeof(uint16_t));
+		HMAC_Update(hctx, (uint8_t const *)label, labellen);
+		HMAC_Update(hctx, (uint8_t *) &L, sizeof(uint16_t));
+		HMAC_Final(hctx, digest, &mdlen);
 		if ((len + (int) mdlen) > resultbytelen) {
 			memcpy(result + len, digest, resultbytelen - len);
 		} else {
 			memcpy(result + len, digest, mdlen);
 		}
 		len += mdlen;
-		HMAC_CTX_cleanup(&hctx);
+#if OPENSSL_VERSION_NUMBER >= 0x10100000L
+		HMAC_CTX_reset(hctx);
+#else
+		HMAC_CTX_cleanup(hctx);
+#endif
 	}
 
 	/* since we're expanding to a bit length, mask off the excess */
@@ -98,6 +108,8 @@ static void eap_pwd_kdf(uint8_t *key, in
 		mask <<= (8 - (resultbitlen % 8));
 		result[resultbytelen - 1] &= mask;
 	}
+
+	HMAC_CTX_free(hctx);
 }
 
 int compute_password_element (pwd_session_t *session, uint16_t grp_num,
@@ -107,7 +119,7 @@ int compute_password_element (pwd_sessio
 			      uint32_t *token)
 {
 	BIGNUM *x_candidate = NULL, *rnd = NULL, *cofactor = NULL;
-	HMAC_CTX ctx;
+	HMAC_CTX *ctx = NULL;
 	uint8_t pwe_digest[SHA256_DIGEST_LENGTH], *prfbuf = NULL, ctr;
 	int nid, is_odd, primebitlen, primebytelen, ret = 0;
 
@@ -177,6 +189,7 @@ int compute_password_element (pwd_sessio
 		DEBUG("unable to alloc space for prf buffer");
 		goto fail;
 	}
+	ctx = HMAC_CTX_new();
 	ctr = 0;
 	while (1) {
 		if (ctr > 10) {
@@ -190,13 +203,13 @@ int compute_password_element (pwd_sessio
 		 *    pwd-seed = H(token | peer-id | server-id | password |
 		 *		   counter)
 		 */
-		H_Init(&ctx);
-		H_Update(&ctx, (uint8_t *)token, sizeof(*token));
-		H_Update(&ctx, (uint8_t const *)id_peer, id_peer_len);
-		H_Update(&ctx, (uint8_t const *)id_server, id_server_len);
-		H_Update(&ctx, (uint8_t const *)password, password_len);
-		H_Update(&ctx, (uint8_t *)&ctr, sizeof(ctr));
-		H_Final(&ctx, pwe_digest);
+		H_Init(ctx);
+		H_Update(ctx, (uint8_t *)token, sizeof(*token));
+		H_Update(ctx, (uint8_t const *)id_peer, id_peer_len);
+		H_Update(ctx, (uint8_t const *)id_server, id_server_len);
+		H_Update(ctx, (uint8_t const *)password, password_len);
+		H_Update(ctx, (uint8_t *)&ctr, sizeof(ctr));
+		H_Final(ctx, pwe_digest);
 
 		BN_bin2bn(pwe_digest, SHA256_DIGEST_LENGTH, rnd);
 		eap_pwd_kdf(pwe_digest, SHA256_DIGEST_LENGTH, "EAP-pwd Hunting And Pecking",
@@ -262,6 +275,7 @@ int compute_password_element (pwd_sessio
 	}
 
 	/* cleanliness and order.... */
+	HMAC_CTX_free(ctx);
 	BN_clear_free(cofactor);
 	BN_clear_free(x_candidate);
 	BN_clear_free(rnd);
@@ -420,7 +434,7 @@ finish:
 int compute_server_confirm (pwd_session_t *session, uint8_t *out, BN_CTX *bnctx)
 {
 	BIGNUM *x = NULL, *y = NULL;
-	HMAC_CTX ctx;
+	HMAC_CTX *ctx = NULL;
 	uint8_t *cruft = NULL;
 	int offset, req = -1;
 
@@ -437,7 +451,8 @@ int compute_server_confirm (pwd_session_
 	 * commit is H(k | server_element | server_scalar | peer_element |
 	 *	       peer_scalar | ciphersuite)
 	 */
-	H_Init(&ctx);
+	ctx = HMAC_CTX_new();
+	H_Init(ctx);
 
 	/*
 	 * Zero the memory each time because this is mod prime math and some
@@ -447,7 +462,7 @@ int compute_server_confirm (pwd_session_
 	 */
 	offset = BN_num_bytes(session->prime) - BN_num_bytes(session->k);
 	BN_bn2bin(session->k, cruft + offset);
-	H_Update(&ctx, cruft, BN_num_bytes(session->prime));
+	H_Update(ctx, cruft, BN_num_bytes(session->prime));
 
 	/*
 	 * next is server element: x, y
@@ -459,12 +474,12 @@ int compute_server_confirm (pwd_session_
 	memset(cruft, 0, BN_num_bytes(session->prime));
 	offset = BN_num_bytes(session->prime) - BN_num_bytes(x);
 	BN_bn2bin(x, cruft + offset);
-	H_Update(&ctx, cruft, BN_num_bytes(session->prime));
+	H_Update(ctx, cruft, BN_num_bytes(session->prime));
 
 	memset(cruft, 0, BN_num_bytes(session->prime));
 	offset = BN_num_bytes(session->prime) - BN_num_bytes(y);
 	BN_bn2bin(y, cruft + offset);
-	H_Update(&ctx, cruft, BN_num_bytes(session->prime));
+	H_Update(ctx, cruft, BN_num_bytes(session->prime));
 
 	/*
 	 * and server scalar
@@ -472,7 +487,7 @@ int compute_server_confirm (pwd_session_
 	memset(cruft, 0, BN_num_bytes(session->prime));
 	offset = BN_num_bytes(session->order) - BN_num_bytes(session->my_scalar);
 	BN_bn2bin(session->my_scalar, cruft + offset);
-	H_Update(&ctx, cruft, BN_num_bytes(session->order));
+	H_Update(ctx, cruft, BN_num_bytes(session->order));
 
 	/*
 	 * next is peer element: x, y
@@ -485,12 +500,12 @@ int compute_server_confirm (pwd_session_
 	memset(cruft, 0, BN_num_bytes(session->prime));
 	offset = BN_num_bytes(session->prime) - BN_num_bytes(x);
 	BN_bn2bin(x, cruft + offset);
-	H_Update(&ctx, cruft, BN_num_bytes(session->prime));
+	H_Update(ctx, cruft, BN_num_bytes(session->prime));
 
 	memset(cruft, 0, BN_num_bytes(session->prime));
 	offset = BN_num_bytes(session->prime) - BN_num_bytes(y);
 	BN_bn2bin(y, cruft + offset);
-	H_Update(&ctx, cruft, BN_num_bytes(session->prime));
+	H_Update(ctx, cruft, BN_num_bytes(session->prime));
 
 	/*
 	 * and peer scalar
@@ -498,17 +513,18 @@ int compute_server_confirm (pwd_session_
 	memset(cruft, 0, BN_num_bytes(session->prime));
 	offset = BN_num_bytes(session->order) - BN_num_bytes(session->peer_scalar);
 	BN_bn2bin(session->peer_scalar, cruft + offset);
-	H_Update(&ctx, cruft, BN_num_bytes(session->order));
+	H_Update(ctx, cruft, BN_num_bytes(session->order));
 
 	/*
 	 * finally, ciphersuite
 	 */
-	H_Update(&ctx, (uint8_t *)&session->ciphersuite, sizeof(session->ciphersuite));
+	H_Update(ctx, (uint8_t *)&session->ciphersuite, sizeof(session->ciphersuite));
 
-	H_Final(&ctx, out);
+	H_Final(ctx, out);
 
 	req = 0;
 finish:
+	HMAC_CTX_free(ctx);
 	talloc_free(cruft);
 	BN_free(x);
 	BN_free(y);
@@ -519,7 +535,7 @@ finish:
 int compute_peer_confirm (pwd_session_t *session, uint8_t *out, BN_CTX *bnctx)
 {
 	BIGNUM *x = NULL, *y = NULL;
-	HMAC_CTX ctx;
+	HMAC_CTX *ctx = NULL;
 	uint8_t *cruft = NULL;
 	int offset, req = -1;
 
@@ -536,7 +552,8 @@ int compute_peer_confirm (pwd_session_t
 	 * commit is H(k | server_element | server_scalar | peer_element |
 	 *	       peer_scalar | ciphersuite)
 	 */
-	H_Init(&ctx);
+	ctx = HMAC_CTX_new();
+	H_Init(ctx);
 
 	/*
 	 * Zero the memory each time because this is mod prime math and some
@@ -546,7 +563,7 @@ int compute_peer_confirm (pwd_session_t
 	 */
 	offset = BN_num_bytes(session->prime) - BN_num_bytes(session->k);
 	BN_bn2bin(session->k, cruft + offset);
-	H_Update(&ctx, cruft, BN_num_bytes(session->prime));
+	H_Update(ctx, cruft, BN_num_bytes(session->prime));
 
 	/*
 	* then peer element: x, y
@@ -559,12 +576,12 @@ int compute_peer_confirm (pwd_session_t
 	memset(cruft, 0, BN_num_bytes(session->prime));
 	offset = BN_num_bytes(session->prime) - BN_num_bytes(x);
 	BN_bn2bin(x, cruft + offset);
-	H_Update(&ctx, cruft, BN_num_bytes(session->prime));
+	H_Update(ctx, cruft, BN_num_bytes(session->prime));
 
 	memset(cruft, 0, BN_num_bytes(session->prime));
 	offset = BN_num_bytes(session->prime) - BN_num_bytes(y);
 	BN_bn2bin(y, cruft + offset);
-	H_Update(&ctx, cruft, BN_num_bytes(session->prime));
+	H_Update(ctx, cruft, BN_num_bytes(session->prime));
 
 	/*
 	 * and peer scalar
@@ -572,7 +589,7 @@ int compute_peer_confirm (pwd_session_t
 	memset(cruft, 0, BN_num_bytes(session->prime));
 	offset = BN_num_bytes(session->order) - BN_num_bytes(session->peer_scalar);
 	BN_bn2bin(session->peer_scalar, cruft + offset);
-	H_Update(&ctx, cruft, BN_num_bytes(session->order));
+	H_Update(ctx, cruft, BN_num_bytes(session->order));
 
 	/*
 	 * then server element: x, y
@@ -584,12 +601,12 @@ int compute_peer_confirm (pwd_session_t
 	memset(cruft, 0, BN_num_bytes(session->prime));
 	offset = BN_num_bytes(session->prime) - BN_num_bytes(x);
 	BN_bn2bin(x, cruft + offset);
-	H_Update(&ctx, cruft, BN_num_bytes(session->prime));
+	H_Update(ctx, cruft, BN_num_bytes(session->prime));
 
 	memset(cruft, 0, BN_num_bytes(session->prime));
 	offset = BN_num_bytes(session->prime) - BN_num_bytes(y);
 	BN_bn2bin(y, cruft + offset);
-	H_Update(&ctx, cruft, BN_num_bytes(session->prime));
+	H_Update(ctx, cruft, BN_num_bytes(session->prime));
 
 	/*
 	 * and server scalar
@@ -597,17 +614,18 @@ int compute_peer_confirm (pwd_session_t
 	memset(cruft, 0, BN_num_bytes(session->prime));
 	offset = BN_num_bytes(session->order) - BN_num_bytes(session->my_scalar);
 	BN_bn2bin(session->my_scalar, cruft + offset);
-	H_Update(&ctx, cruft, BN_num_bytes(session->order));
+	H_Update(ctx, cruft, BN_num_bytes(session->order));
 
 	/*
 	 * finally, ciphersuite
 	 */
-	H_Update(&ctx, (uint8_t *)&session->ciphersuite, sizeof(session->ciphersuite));
+	H_Update(ctx, (uint8_t *)&session->ciphersuite, sizeof(session->ciphersuite));
 
-	H_Final(&ctx, out);
+	H_Final(ctx, out);
 
 	req = 0;
 finish:
+	HMAC_CTX_free(ctx);
 	talloc_free(cruft);
 	BN_free(x);
 	BN_free(y);
@@ -617,7 +635,7 @@ finish:
 
 int compute_keys (pwd_session_t *session, uint8_t *peer_confirm, uint8_t *msk, uint8_t *emsk)
 {
-	HMAC_CTX ctx;
+	HMAC_CTX *ctx;
 	uint8_t mk[SHA256_DIGEST_LENGTH], *cruft;
 	uint8_t session_id[SHA256_DIGEST_LENGTH + 1];
 	uint8_t msk_emsk[128];		/* 64 each */
@@ -628,36 +646,38 @@ int compute_keys (pwd_session_t *session
 		return -1;
 	}
 
+	ctx = HMAC_CTX_new();
+
 	/*
 	 * first compute the session-id = TypeCode | H(ciphersuite | scal_p |
 	 *	scal_s)
 	 */
 	session_id[0] = PW_EAP_PWD;
-	H_Init(&ctx);
-	H_Update(&ctx, (uint8_t *)&session->ciphersuite, sizeof(session->ciphersuite));
+	H_Init(ctx);
+	H_Update(ctx, (uint8_t *)&session->ciphersuite, sizeof(session->ciphersuite));
 	offset = BN_num_bytes(session->order) - BN_num_bytes(session->peer_scalar);
 	memset(cruft, 0, BN_num_bytes(session->prime));
 	BN_bn2bin(session->peer_scalar, cruft + offset);
-	H_Update(&ctx, cruft, BN_num_bytes(session->order));
+	H_Update(ctx, cruft, BN_num_bytes(session->order));
 	offset = BN_num_bytes(session->order) - BN_num_bytes(session->my_scalar);
 	memset(cruft, 0, BN_num_bytes(session->prime));
 	BN_bn2bin(session->my_scalar, cruft + offset);
-	H_Update(&ctx, cruft, BN_num_bytes(session->order));
-	H_Final(&ctx, (uint8_t *)&session_id[1]);
+	H_Update(ctx, cruft, BN_num_bytes(session->order));
+	H_Final(ctx, (uint8_t *)&session_id[1]);
 
 	/* then compute MK = H(k | commit-peer | commit-server) */
-	H_Init(&ctx);
+	H_Init(ctx);
 
 	memset(cruft, 0, BN_num_bytes(session->prime));
 	offset = BN_num_bytes(session->prime) - BN_num_bytes(session->k);
 	BN_bn2bin(session->k, cruft + offset);
-	H_Update(&ctx, cruft, BN_num_bytes(session->prime));
+	H_Update(ctx, cruft, BN_num_bytes(session->prime));
 
-	H_Update(&ctx, peer_confirm, SHA256_DIGEST_LENGTH);
+	H_Update(ctx, peer_confirm, SHA256_DIGEST_LENGTH);
 
-	H_Update(&ctx, session->my_confirm, SHA256_DIGEST_LENGTH);
+	H_Update(ctx, session->my_confirm, SHA256_DIGEST_LENGTH);
 
-	H_Final(&ctx, mk);
+	H_Final(ctx, mk);
 
 	/* stretch the mk with the session-id to get MSK | EMSK */
 	eap_pwd_kdf(mk, SHA256_DIGEST_LENGTH, (char const *)session_id,
@@ -666,6 +686,7 @@ int compute_keys (pwd_session_t *session
 	memcpy(msk, msk_emsk, 64);
 	memcpy(emsk, msk_emsk + 64, 64);
 
+	HMAC_CTX_free(ctx);
 	talloc_free(cruft);
 	return 0;
 }
Index: freeradius-new/src/modules/rlm_eap/libeap/mppe_keys.c
===================================================================
--- freeradius-new.orig/src/modules/rlm_eap/libeap/mppe_keys.c
+++ freeradius-new/src/modules/rlm_eap/libeap/mppe_keys.c
@@ -37,51 +37,51 @@ static void P_hash(EVP_MD const *evp_md,
 		   unsigned char const *seed,   unsigned int seed_len,
 		   unsigned char *out, unsigned int out_len)
 {
-	HMAC_CTX ctx_a, ctx_out;
+	HMAC_CTX *ctx_a, *ctx_out;
 	unsigned char a[HMAC_MAX_MD_CBLOCK];
 	unsigned int size;
 
-	HMAC_CTX_init(&ctx_a);
-	HMAC_CTX_init(&ctx_out);
+	ctx_a = HMAC_CTX_new();
+	ctx_out = HMAC_CTX_new();
 #ifdef EVP_MD_CTX_FLAG_NON_FIPS_ALLOW
-	HMAC_CTX_set_flags(&ctx_a, EVP_MD_CTX_FLAG_NON_FIPS_ALLOW);
-	HMAC_CTX_set_flags(&ctx_out, EVP_MD_CTX_FLAG_NON_FIPS_ALLOW);
+	HMAC_CTX_set_flags(ctx_a, EVP_MD_CTX_FLAG_NON_FIPS_ALLOW);
+	HMAC_CTX_set_flags(ctx_out, EVP_MD_CTX_FLAG_NON_FIPS_ALLOW);
 #endif
-	HMAC_Init_ex(&ctx_a, secret, secret_len, evp_md, NULL);
-	HMAC_Init_ex(&ctx_out, secret, secret_len, evp_md, NULL);
+	HMAC_Init_ex(ctx_a, secret, secret_len, evp_md, NULL);
+	HMAC_Init_ex(ctx_out, secret, secret_len, evp_md, NULL);
 
-	size = HMAC_size(&ctx_out);
+	size = HMAC_size(ctx_out);
 
 	/* Calculate A(1) */
-	HMAC_Update(&ctx_a, seed, seed_len);
-	HMAC_Final(&ctx_a, a, NULL);
+	HMAC_Update(ctx_a, seed, seed_len);
+	HMAC_Final(ctx_a, a, NULL);
 
 	while (1) {
 		/* Calculate next part of output */
-		HMAC_Update(&ctx_out, a, size);
-		HMAC_Update(&ctx_out, seed, seed_len);
+		HMAC_Update(ctx_out, a, size);
+		HMAC_Update(ctx_out, seed, seed_len);
 
 		/* Check if last part */
 		if (out_len < size) {
-			HMAC_Final(&ctx_out, a, NULL);
+			HMAC_Final(ctx_out, a, NULL);
 			memcpy(out, a, out_len);
 			break;
 		}
 
 		/* Place digest in output buffer */
-		HMAC_Final(&ctx_out, out, NULL);
-		HMAC_Init_ex(&ctx_out, NULL, 0, NULL, NULL);
+		HMAC_Final(ctx_out, out, NULL);
+		HMAC_Init_ex(ctx_out, NULL, 0, NULL, NULL);
 		out += size;
 		out_len -= size;
 
 		/* Calculate next A(i) */
-		HMAC_Init_ex(&ctx_a, NULL, 0, NULL, NULL);
-		HMAC_Update(&ctx_a, a, size);
-		HMAC_Final(&ctx_a, a, NULL);
+		HMAC_Init_ex(ctx_a, NULL, 0, NULL, NULL);
+		HMAC_Update(ctx_a, a, size);
+		HMAC_Final(ctx_a, a, NULL);
 	}
 
-	HMAC_CTX_cleanup(&ctx_a);
-	HMAC_CTX_cleanup(&ctx_out);
+	HMAC_CTX_free(ctx_a);
+	HMAC_CTX_free(ctx_out);
 	memset(a, 0, sizeof(a));
 }
 
@@ -263,19 +263,37 @@ void eap_fast_tls_gen_challenge(SSL *s,
 	uint8_t seed[128 + 2*SSL3_RANDOM_SIZE];
 	uint8_t *p = seed;
 	size_t len;
+	const SSL_SESSION *session = SSL_get_session(s);
 
 	len = strlen(prf_label);
 	if (len > 128) len = 128;
 
 	memcpy(p, prf_label, len);
 	p += len;
+#ifdef HAVE_SSL_GET_CLIENT_RANDOM
+	SSL_get_server_random(s, p, SSL3_RANDOM_SIZE);
+#else
 	memcpy(p, s->s3->server_random, SSL3_RANDOM_SIZE);
+#endif
 	p += SSL3_RANDOM_SIZE;
+#ifdef HAVE_SSL_GET_CLIENT_RANDOM
+	SSL_get_client_random(s, p, SSL3_RANDOM_SIZE);
+#else
 	memcpy(p, s->s3->client_random, SSL3_RANDOM_SIZE);
+#endif
 	p += SSL3_RANDOM_SIZE;
 
+#if OPENSSL_VERSION_NUMBER >= 0x10100000L
+	const size_t master_key_len = SSL_SESSION_get_master_key(session, NULL, 0);
+	uint8_t *master_key = talloc_zero_size(NULL, master_key_len);
+	SSL_SESSION_get_master_key(session, master_key, master_key_len);
+	PRF(master_key, master_key_len,
+	    seed, p - seed, buffer, scratch, size);
+	talloc_free(master_key);
+#else
 	PRF(s->session->master_key, s->session->master_key_length,
 	    seed, p - seed, buffer, scratch, size);
+#endif
 }
 
 
Index: freeradius-new/src/include/tls-h
===================================================================
--- freeradius-new.orig/src/include/tls-h
+++ freeradius-new/src/include/tls-h
@@ -46,6 +46,23 @@ RCSIDH(tls_h, "$Id: 9142b91e2a7d39011331
 extern "C" {
 #endif
 
+#if OPENSSL_VERSION_NUMBER < 0x10100000L
+static inline HMAC_CTX *HMAC_CTX_new(void)
+{
+	HMAC_CTX *ctx;
+	ctx = talloc(NULL, HMAC_CTX);
+	HMAC_CTX_init(ctx);
+	return ctx;
+}
+#  define HMAC_CTX_free(_ctx) \
+do {\
+	if (_ctx) {\
+		memset(_ctx, 0, sizeof(*_ctx));\
+		talloc_free(_ctx);\
+	}\
+} while (0)
+#endif
+
 typedef struct fr_tls_server_conf_t fr_tls_server_conf_t;
 
 typedef enum {
Index: freeradius-new/src/modules/rlm_eap/types/rlm_eap_fast/rlm_eap_fast.c
===================================================================
--- freeradius-new.orig/src/modules/rlm_eap/types/rlm_eap_fast/rlm_eap_fast.c
+++ freeradius-new/src/modules/rlm_eap/types/rlm_eap_fast/rlm_eap_fast.c
@@ -206,8 +206,8 @@ static int _session_secret(SSL *s, void
 #if OPENSSL_VERSION_NUMBER < 0x10100000L || defined(LIBRESSL_VERSION_NUMBER)
 	eap_fast_session_ticket(tls_session, s->s3->client_random, s->s3->server_random, secret, secret_len);
 #else
-	uint8_t const client_random[SSL3_RANDOM_SIZE];
-	uint8_t const server_random[SSL3_RANDOM_SIZE];
+	uint8_t client_random[SSL3_RANDOM_SIZE];
+	uint8_t server_random[SSL3_RANDOM_SIZE];
 
 	SSL_get_client_random(s, client_random, sizeof(client_random));
 	SSL_get_server_random(s, server_random, sizeof(server_random));