This repository has been archived by the owner on Jun 9, 2018. It is now read-only.
/
digest_t.in
79 lines (63 loc) · 1.49 KB
/
digest_t.in
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
#! parrot
# Copyright (C) 2009-2010, Parrot Foundation.
=head1 NAME
t/@TEMP_md_file@.t - test the @TEMP_md_name@ PMC (part of digest_group)
=head1 SYNOPSIS
% parrot t/@TEMP_md_file@.t
=head1 DESCRIPTION
Tests the C<digest_group> a libcrypto wrapper.
=cut
.include 'iglobals.pasm'
.sub 'main' :main
.include 'test_more.pir'
plan(2)
.local pmc config
$P0 = getinterp
config = $P0[.IGLOBALS_CONFIG_HASH]
$S0 = config['has_crypto']
$S1 = config['openssl_version']
unless $S0 goto no_crypto
if $S1 < '@TEMP_md_skip@' goto old_openssl
$P0 = loadlib 'digest_group'
test_typeof()
test_digest()
.return()
no_crypto:
skip(2, 'No crypto library available')
.return()
old_openssl:
skip(2, 'Too old openssl library, needs at least @TEMP_md_skip@')
.end
.sub 'test_typeof'
.local pmc md
md = new '@TEMP_md_name@'
$S0 = typeof md
is($S0, '@TEMP_md_name@', '@TEMP_md_name@ typeof')
.end
.sub 'test_digest'
.local pmc md
md = new '@TEMP_md_name@'
md.'Init'()
$S0 = 'message digest'
md.'Update'($S0)
$S0 = md.'Final'()
$P0 = split '', $S0
new $P1, 'FixedPMCArray'
set $P1, 1
$S3 = ''
L1:
unless $P0 goto L2
$S1 = shift $P0
$I1 = ord $S1
$P1[0] = $I1
$S2 = sprintf '%02x', $P1
$S3 .= $S2
goto L1
L2:
is($S3, '@TEMP_md_result@', '@TEMP_md_name@ digest')
.end
# Local Variables:
# mode: pir
# fill-column: 100
# End:
# vim: expandtab shiftwidth=4 ft=pir: