-
Notifications
You must be signed in to change notification settings - Fork 96
/
evpmd.c
635 lines (551 loc) · 16.1 KB
/
evpmd.c
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
/*
* OpenSSL API (EVP MD) - Harbour interface.
*
* Copyright 2009-2016 Viktor Szakats
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2, or (at your option)
* any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; see the file LICENSE.txt. If not, write to
* the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
* Boston, MA 02110-1301 USA (or visit https://www.gnu.org/licenses/).
*
* As a special exception, the Harbour Project gives permission for
* additional uses of the text contained in its release of Harbour.
*
* The exception is that, if you link the Harbour libraries with other
* files to produce an executable, this does not by itself cause the
* resulting executable to be covered by the GNU General Public License.
* Your use of that executable is in no way restricted on account of
* linking the Harbour library code into it.
*
* This exception does not however invalidate any other reasons why
* the executable file might be covered by the GNU General Public License.
*
* This exception applies only to the code released by the Harbour
* Project under the name Harbour. If you copy code from other
* Harbour Project or Free Software Foundation releases into a copy of
* Harbour, as the General Public License permits, the exception does
* not apply to the code that you add in this way. To avoid misleading
* anyone as to the status of such modified files, you must delete
* this exception notice from them.
*
* If you write modifications of your own for Harbour, it is your choice
* whether to permit this exception to apply to your modifications.
* If you do not wish that, delete this exception notice.
*
*/
#include "hbssl.h"
#include "hbapiitm.h"
#include <openssl/evp.h>
#if OPENSSL_VERSION_NUMBER < 0x10100000L
#define EVP_MD_CTX_new EVP_MD_CTX_create
#define EVP_MD_CTX_free EVP_MD_CTX_destroy
#endif
HB_FUNC( OPENSSL_ADD_ALL_DIGESTS )
{
OpenSSL_add_all_digests();
}
static HB_GARBAGE_FUNC( EVP_MD_CTX_release )
{
void ** ph = ( void ** ) Cargo;
/* Check if pointer is not NULL to avoid multiple freeing */
if( ph && *ph )
{
/* Destroy the object */
#if defined( LIBRESSL_VERSION_NUMBER )
EVP_MD_CTX_destroy( ( EVP_MD_CTX * ) *ph );
#elif OPENSSL_VERSION_NUMBER >= 0x00907000L
EVP_MD_CTX_free( ( EVP_MD_CTX * ) *ph );
#else
hb_xfree( *ph );
#endif
/* set pointer to NULL just in case */
*ph = NULL;
}
}
static const HB_GC_FUNCS s_gcEVP_MD_CTX_funcs =
{
EVP_MD_CTX_release,
hb_gcDummyMark
};
static HB_BOOL hb_EVP_MD_CTX_is( int iParam )
{
return hb_parptrGC( &s_gcEVP_MD_CTX_funcs, iParam ) != NULL;
}
static EVP_MD_CTX * hb_EVP_MD_CTX_par( int iParam )
{
void ** ph = ( void ** ) hb_parptrGC( &s_gcEVP_MD_CTX_funcs, iParam );
return ph ? ( EVP_MD_CTX * ) *ph : NULL;
}
HB_BOOL hb_EVP_MD_is( int iParam )
{
return HB_ISCHAR( iParam ) || HB_ISNUM( iParam );
}
const EVP_MD * hb_EVP_MD_par( int iParam )
{
const EVP_MD * p;
if( HB_ISCHAR( iParam ) )
return EVP_get_digestbyname( hb_parc( iParam ) );
switch( hb_parni( iParam ) )
{
case HB_EVP_MD_MD_NULL: p = EVP_md_null(); break;
#ifndef OPENSSL_NO_MD4
case HB_EVP_MD_MD4: p = EVP_md4(); break;
#endif
#ifndef OPENSSL_NO_MD5
case HB_EVP_MD_MD5: p = EVP_md5(); break;
#endif
#ifndef OPENSSL_NO_SHA
#if OPENSSL_VERSION_NUMBER < 0x10100000L && \
! defined( LIBRESSL_VERSION_NUMBER )
case HB_EVP_MD_SHA: p = EVP_sha(); break;
#endif
case HB_EVP_MD_SHA1: p = EVP_sha1(); break;
#if OPENSSL_VERSION_NUMBER < 0x10100000L
case HB_EVP_MD_DSS: p = EVP_dss(); break;
case HB_EVP_MD_DSS1: p = EVP_dss1(); break;
#endif
#if OPENSSL_VERSION_NUMBER >= 0x00908000L && \
OPENSSL_VERSION_NUMBER < 0x10100000L
case HB_EVP_MD_ECDSA: p = EVP_ecdsa(); break;
#endif
#endif
#ifndef OPENSSL_NO_SHA256
case HB_EVP_MD_SHA224: p = EVP_sha224(); break;
case HB_EVP_MD_SHA256: p = EVP_sha256(); break;
#endif
#ifndef OPENSSL_NO_SHA512
case HB_EVP_MD_SHA384: p = EVP_sha384(); break;
case HB_EVP_MD_SHA512: p = EVP_sha512(); break;
#endif
#ifndef OPENSSL_NO_RIPEMD
case HB_EVP_MD_RIPEMD160: p = EVP_ripemd160(); break;
#endif
default: p = NULL;
}
return p;
}
static int hb_EVP_MD_ptr_to_id( const EVP_MD * p )
{
int n;
if( p == EVP_md_null() ) n = HB_EVP_MD_MD_NULL;
#ifndef OPENSSL_NO_MD4
else if( p == EVP_md4() ) n = HB_EVP_MD_MD4;
#endif
#ifndef OPENSSL_NO_MD5
else if( p == EVP_md5() ) n = HB_EVP_MD_MD5;
#endif
#ifndef OPENSSL_NO_SHA
#if OPENSSL_VERSION_NUMBER < 0x10100000L && \
! defined( LIBRESSL_VERSION_NUMBER )
else if( p == EVP_sha() ) n = HB_EVP_MD_SHA;
#endif
else if( p == EVP_sha1() ) n = HB_EVP_MD_SHA1;
#if OPENSSL_VERSION_NUMBER < 0x10100000L
else if( p == EVP_dss() ) n = HB_EVP_MD_DSS;
else if( p == EVP_dss1() ) n = HB_EVP_MD_DSS1;
#endif
#if OPENSSL_VERSION_NUMBER >= 0x00908000L && \
OPENSSL_VERSION_NUMBER < 0x10100000L
else if( p == EVP_ecdsa() ) n = HB_EVP_MD_ECDSA;
#endif
#endif
#ifndef OPENSSL_NO_SHA256
else if( p == EVP_sha224() ) n = HB_EVP_MD_SHA224;
else if( p == EVP_sha256() ) n = HB_EVP_MD_SHA256;
#endif
#ifndef OPENSSL_NO_SHA512
else if( p == EVP_sha384() ) n = HB_EVP_MD_SHA384;
else if( p == EVP_sha512() ) n = HB_EVP_MD_SHA512;
#endif
#ifndef OPENSSL_NO_RIPEMD
else if( p == EVP_ripemd160() ) n = HB_EVP_MD_RIPEMD160;
#endif
else n = HB_EVP_MD_UNSUPPORTED;
return n;
}
HB_FUNC( EVP_GET_DIGESTBYNAME )
{
if( HB_ISCHAR( 1 ) )
hb_retni( hb_EVP_MD_ptr_to_id( EVP_get_digestbyname( hb_parc( 1 ) ) ) );
else
hb_errRT_BASE( EG_ARG, 2010, NULL, HB_ERR_FUNCNAME, HB_ERR_ARGS_BASEPARAMS );
}
HB_FUNC( EVP_GET_DIGESTBYNID )
{
if( HB_ISNUM( 1 ) )
hb_retni( hb_EVP_MD_ptr_to_id( EVP_get_digestbynid( hb_parni( 1 ) ) ) );
else
hb_errRT_BASE( EG_ARG, 2010, NULL, HB_ERR_FUNCNAME, HB_ERR_ARGS_BASEPARAMS );
}
HB_FUNC( EVP_MD_TYPE )
{
const EVP_MD * md = hb_EVP_MD_par( 1 );
hb_retni( md ? EVP_MD_type( md ) : 0 );
}
HB_FUNC( EVP_MD_NID )
{
const EVP_MD * md = hb_EVP_MD_par( 1 );
#if OPENSSL_VERSION_NUMBER >= 0x00907000L
hb_retni( md ? EVP_MD_nid( md ) : 0 );
#else
hb_retni( md ? EVP_MD_type( md ) : 0 );
#endif
}
HB_FUNC( EVP_MD_PKEY_TYPE )
{
const EVP_MD * md = hb_EVP_MD_par( 1 );
hb_retni( md ? EVP_MD_pkey_type( md ) : 0 );
}
HB_FUNC( EVP_MD_SIZE )
{
const EVP_MD * md = hb_EVP_MD_par( 1 );
hb_retni( md ? EVP_MD_size( md ) : 0 );
}
HB_FUNC( EVP_MD_BLOCK_SIZE )
{
const EVP_MD * md = hb_EVP_MD_par( 1 );
hb_retni( md ? EVP_MD_block_size( md ) : 0 );
}
HB_FUNC( EVP_MD_CTX_NEW )
{
void ** ph = ( void ** ) hb_gcAllocate( sizeof( EVP_MD_CTX * ), &s_gcEVP_MD_CTX_funcs );
EVP_MD_CTX * ctx;
#if OPENSSL_VERSION_NUMBER >= 0x00907000L && \
! defined( LIBRESSL_VERSION_NUMBER )
ctx = EVP_MD_CTX_new();
#else
ctx = ( EVP_MD_CTX * ) hb_xgrabz( sizeof( EVP_MD_CTX ) );
#endif
*ph = ctx;
hb_retptrGC( ph );
}
#if defined( HB_LEGACY_LEVEL5 )
HB_FUNC_TRANSLATE( EVP_MD_CTX_CREATE, EVP_MD_CTX_NEW )
#endif
HB_FUNC( EVP_MD_CTX_RESET )
{
if( hb_EVP_MD_CTX_is( 1 ) )
{
EVP_MD_CTX * ctx = hb_EVP_MD_CTX_par( 1 );
if( ctx )
{
#if defined( LIBRESSL_VERSION_NUMBER )
hb_retni( EVP_MD_CTX_cleanup( ctx ) );
#elif OPENSSL_VERSION_NUMBER >= 0x10100000L
hb_retni( EVP_MD_CTX_reset( ctx ) );
#elif OPENSSL_VERSION_NUMBER >= 0x00907000L
hb_retni( EVP_MD_CTX_cleanup( ctx ) );
#else
hb_retni( 0 );
#endif
}
}
else
hb_errRT_BASE( EG_ARG, 2010, NULL, HB_ERR_FUNCNAME, HB_ERR_ARGS_BASEPARAMS );
}
#if defined( HB_LEGACY_LEVEL5 )
HB_FUNC_TRANSLATE( EVP_MD_CTX_INIT, EVP_MD_CTX_RESET )
HB_FUNC_TRANSLATE( EVP_MD_CTX_CLEANUP, EVP_MD_CTX_RESET )
#endif
HB_FUNC( EVP_MD_CTX_MD )
{
if( hb_EVP_MD_CTX_is( 1 ) )
{
EVP_MD_CTX * ctx = hb_EVP_MD_CTX_par( 1 );
if( ctx )
hb_retni( hb_EVP_MD_ptr_to_id( EVP_MD_CTX_md( ctx ) ) );
}
else
hb_errRT_BASE( EG_ARG, 2010, NULL, HB_ERR_FUNCNAME, HB_ERR_ARGS_BASEPARAMS );
}
HB_FUNC( EVP_MD_CTX_COPY )
{
if( hb_EVP_MD_CTX_is( 1 ) && hb_EVP_MD_CTX_is( 2 ) )
{
EVP_MD_CTX * ctx_out = hb_EVP_MD_CTX_par( 1 );
EVP_MD_CTX * ctx_in = hb_EVP_MD_CTX_par( 2 );
if( ctx_out && ctx_in )
hb_retni( EVP_MD_CTX_copy( ctx_out, ctx_in ) );
}
else
hb_errRT_BASE( EG_ARG, 2010, NULL, HB_ERR_FUNCNAME, HB_ERR_ARGS_BASEPARAMS );
}
HB_FUNC( EVP_MD_CTX_COPY_EX )
{
if( hb_EVP_MD_CTX_is( 1 ) && hb_EVP_MD_CTX_is( 2 ) )
{
EVP_MD_CTX * ctx_out = hb_EVP_MD_CTX_par( 1 );
EVP_MD_CTX * ctx_in = hb_EVP_MD_CTX_par( 2 );
if( ctx_out && ctx_in )
{
#if OPENSSL_VERSION_NUMBER >= 0x00907000L
hb_retni( EVP_MD_CTX_copy_ex( ctx_out, ctx_in ) );
#else
hb_retni( 0 );
#endif
}
}
else
hb_errRT_BASE( EG_ARG, 2010, NULL, HB_ERR_FUNCNAME, HB_ERR_ARGS_BASEPARAMS );
}
HB_FUNC( EVP_DIGESTINIT )
{
const EVP_MD * md = hb_EVP_MD_par( 2 );
if( hb_EVP_MD_CTX_is( 1 ) && md )
{
EVP_MD_CTX * ctx = hb_EVP_MD_CTX_par( 1 );
if( ctx )
{
#if OPENSSL_VERSION_NUMBER >= 0x00907000L
hb_retni( EVP_DigestInit( ctx, md ) );
#else
EVP_DigestInit( ctx, md );
hb_retni( 1 );
#endif
}
}
else
hb_errRT_BASE( EG_ARG, 2010, NULL, HB_ERR_FUNCNAME, HB_ERR_ARGS_BASEPARAMS );
}
HB_FUNC( EVP_DIGESTINIT_EX )
{
const EVP_MD * md = hb_EVP_MD_par( 2 );
if( hb_EVP_MD_CTX_is( 1 ) && md )
{
EVP_MD_CTX * ctx = hb_EVP_MD_CTX_par( 1 );
if( ctx )
{
#if OPENSSL_VERSION_NUMBER >= 0x00907000L
hb_retni( EVP_DigestInit_ex( ctx, md, ( ENGINE * ) hb_parptr( 3 ) ) );
#else
hb_retni( 0 );
#endif
}
}
else
hb_errRT_BASE( EG_ARG, 2010, NULL, HB_ERR_FUNCNAME, HB_ERR_ARGS_BASEPARAMS );
}
HB_FUNC( EVP_DIGESTUPDATE )
{
if( hb_EVP_MD_CTX_is( 1 ) )
{
EVP_MD_CTX * ctx = hb_EVP_MD_CTX_par( 1 );
if( ctx )
{
#if OPENSSL_VERSION_NUMBER >= 0x00907000L
hb_retni( EVP_DigestUpdate( ctx, hb_parcx( 2 ), ( size_t ) hb_parclen( 2 ) ) );
#else
EVP_DigestUpdate( ctx, hb_parcx( 2 ), ( size_t ) hb_parclen( 2 ) );
hb_retni( 1 );
#endif
}
}
else
hb_errRT_BASE( EG_ARG, 2010, NULL, HB_ERR_FUNCNAME, HB_ERR_ARGS_BASEPARAMS );
}
HB_FUNC( EVP_DIGESTFINAL )
{
if( hb_EVP_MD_CTX_is( 1 ) )
{
EVP_MD_CTX * ctx = hb_EVP_MD_CTX_par( 1 );
if( ctx )
{
unsigned char * buffer = ( unsigned char * ) hb_xgrab( EVP_MAX_MD_SIZE + 1 );
unsigned int size = 0;
#if OPENSSL_VERSION_NUMBER >= 0x00907000L
hb_retni( EVP_DigestFinal( ctx, buffer, &size ) );
#else
EVP_DigestFinal( ctx, buffer, &size );
hb_retni( 1 );
#endif
if( size > 0 )
{
if( ! hb_storclen_buffer( ( char * ) buffer, ( HB_SIZE ) size, 2 ) )
hb_xfree( buffer );
}
else
{
hb_xfree( buffer );
hb_storc( NULL, 2 );
}
}
}
else
hb_errRT_BASE( EG_ARG, 2010, NULL, HB_ERR_FUNCNAME, HB_ERR_ARGS_BASEPARAMS );
}
HB_FUNC( EVP_DIGESTFINAL_EX )
{
if( hb_EVP_MD_CTX_is( 1 ) )
{
EVP_MD_CTX * ctx = hb_EVP_MD_CTX_par( 1 );
if( ctx )
{
#if OPENSSL_VERSION_NUMBER >= 0x00907000L
unsigned char * buffer = ( unsigned char * ) hb_xgrab( EVP_MAX_MD_SIZE + 1 );
unsigned int size = 0;
hb_retni( EVP_DigestFinal_ex( ctx, buffer, &size ) );
if( size > 0 )
{
if( ! hb_storclen_buffer( ( char * ) buffer, ( HB_SIZE ) size, 2 ) )
hb_xfree( buffer );
}
else
{
hb_xfree( buffer );
hb_storc( NULL, 2 );
}
#endif
}
}
else
hb_errRT_BASE( EG_ARG, 2010, NULL, HB_ERR_FUNCNAME, HB_ERR_ARGS_BASEPARAMS );
}
HB_FUNC( EVP_SIGNINIT )
{
const EVP_MD * md = hb_EVP_MD_par( 2 );
if( hb_EVP_MD_CTX_is( 1 ) && md )
{
EVP_MD_CTX * ctx = hb_EVP_MD_CTX_par( 1 );
if( ctx )
EVP_SignInit( ctx, md );
}
else
hb_errRT_BASE( EG_ARG, 2010, NULL, HB_ERR_FUNCNAME, HB_ERR_ARGS_BASEPARAMS );
}
HB_FUNC( EVP_SIGNINIT_EX )
{
const EVP_MD * md = hb_EVP_MD_par( 2 );
if( hb_EVP_MD_CTX_is( 1 ) && md )
{
EVP_MD_CTX * ctx = hb_EVP_MD_CTX_par( 1 );
if( ctx )
{
#if OPENSSL_VERSION_NUMBER >= 0x00907000L
hb_retni( EVP_SignInit_ex( ctx, md, ( ENGINE * ) hb_parptr( 3 ) ) );
#else
hb_retni( 0 );
#endif
}
}
else
hb_errRT_BASE( EG_ARG, 2010, NULL, HB_ERR_FUNCNAME, HB_ERR_ARGS_BASEPARAMS );
}
HB_FUNC( EVP_SIGNUPDATE )
{
if( hb_EVP_MD_CTX_is( 1 ) )
{
EVP_MD_CTX * ctx = hb_EVP_MD_CTX_par( 1 );
if( ctx )
{
#if OPENSSL_VERSION_NUMBER >= 0x00907000L
hb_retni( EVP_SignUpdate( ctx, hb_parcx( 2 ), ( size_t ) hb_parclen( 2 ) ) );
#else
EVP_SignUpdate( ctx, hb_parcx( 2 ), ( size_t ) hb_parclen( 2 ) );
hb_retni( 1 );
#endif
}
}
else
hb_errRT_BASE( EG_ARG, 2010, NULL, HB_ERR_FUNCNAME, HB_ERR_ARGS_BASEPARAMS );
}
HB_FUNC( EVP_SIGNFINAL )
{
if( hb_EVP_MD_CTX_is( 1 ) && hb_EVP_PKEY_is( 3 ) )
{
EVP_MD_CTX * ctx = hb_EVP_MD_CTX_par( 1 );
if( ctx )
{
unsigned char * buffer = ( unsigned char * ) hb_xgrab( EVP_PKEY_size( hb_EVP_PKEY_par( 3 ) ) + 1 );
unsigned int size = 0;
hb_retni( EVP_SignFinal( ctx, buffer, &size, hb_EVP_PKEY_par( 3 ) ) );
if( size > 0 )
{
if( ! hb_storclen_buffer( ( char * ) buffer, ( HB_SIZE ) size, 2 ) )
hb_xfree( buffer );
}
else
{
hb_xfree( buffer );
hb_storc( NULL, 2 );
}
}
}
else
hb_errRT_BASE( EG_ARG, 2010, NULL, HB_ERR_FUNCNAME, HB_ERR_ARGS_BASEPARAMS );
}
HB_FUNC( EVP_VERIFYINIT )
{
const EVP_MD * md = hb_EVP_MD_par( 2 );
if( hb_EVP_MD_CTX_is( 1 ) && md )
{
EVP_MD_CTX * ctx = hb_EVP_MD_CTX_par( 1 );
if( ctx )
{
#if OPENSSL_VERSION_NUMBER >= 0x00907000L
hb_retni( EVP_VerifyInit( ctx, md ) );
#else
EVP_VerifyInit( ctx, md );
hb_retni( 1 );
#endif
}
}
else
hb_errRT_BASE( EG_ARG, 2010, NULL, HB_ERR_FUNCNAME, HB_ERR_ARGS_BASEPARAMS );
}
HB_FUNC( EVP_VERIFYINIT_EX )
{
const EVP_MD * md = hb_EVP_MD_par( 2 );
if( hb_EVP_MD_CTX_is( 1 ) && md )
{
EVP_MD_CTX * ctx = hb_EVP_MD_CTX_par( 1 );
if( ctx )
{
#if OPENSSL_VERSION_NUMBER >= 0x00907000L
hb_retni( EVP_VerifyInit_ex( ctx, md, ( ENGINE * ) hb_parptr( 3 ) ) );
#else
hb_retni( 0 );
#endif
}
}
else
hb_errRT_BASE( EG_ARG, 2010, NULL, HB_ERR_FUNCNAME, HB_ERR_ARGS_BASEPARAMS );
}
HB_FUNC( EVP_VERIFYUPDATE )
{
if( hb_EVP_MD_CTX_is( 1 ) )
{
EVP_MD_CTX * ctx = hb_EVP_MD_CTX_par( 1 );
if( ctx )
{
#if OPENSSL_VERSION_NUMBER >= 0x00907000L
hb_retni( EVP_VerifyUpdate( ctx, hb_parcx( 2 ), ( size_t ) hb_parclen( 2 ) ) );
#else
EVP_VerifyUpdate( ctx, hb_parcx( 2 ), ( size_t ) hb_parclen( 2 ) );
hb_retni( 1 );
#endif
}
}
else
hb_errRT_BASE( EG_ARG, 2010, NULL, HB_ERR_FUNCNAME, HB_ERR_ARGS_BASEPARAMS );
}
HB_FUNC( EVP_VERIFYFINAL )
{
if( hb_EVP_MD_CTX_is( 1 ) && hb_EVP_PKEY_is( 3 ) )
{
EVP_MD_CTX * ctx = hb_EVP_MD_CTX_par( 1 );
if( ctx )
hb_retni( EVP_VerifyFinal( ctx, ( HB_SSL_CONST unsigned char * ) hb_parcx( 2 ), ( unsigned int ) hb_parclen( 2 ), hb_EVP_PKEY_par( 3 ) ) );
}
else
hb_errRT_BASE( EG_ARG, 2010, NULL, HB_ERR_FUNCNAME, HB_ERR_ARGS_BASEPARAMS );
}