9 {1,1,1,224,224,224,256,256,256,384,384,384,512,512,512};
11 MODULE = Digest::SHA PACKAGE = Digest::SHA
19 #define INT2PTR(p, i) (p) (i)
48 shawrite(bitstr, bitcnt, s)
49 unsigned char * bitstr
57 Digest::SHA::sha1_hex = 1
58 Digest::SHA::sha1_base64 = 2
59 Digest::SHA::sha224 = 3
60 Digest::SHA::sha224_hex = 4
61 Digest::SHA::sha224_base64 = 5
62 Digest::SHA::sha256 = 6
63 Digest::SHA::sha256_hex = 7
64 Digest::SHA::sha256_base64 = 8
65 Digest::SHA::sha384 = 9
66 Digest::SHA::sha384_hex = 10
67 Digest::SHA::sha384_base64 = 11
68 Digest::SHA::sha512 = 12
69 Digest::SHA::sha512_hex = 13
70 Digest::SHA::sha512_base64 = 14
78 if ((state = shaopen(ix2alg[ix])) == NULL)
80 for (i = 0; i < items; i++) {
81 data = (unsigned char *) (SvPV(ST(i), len));
82 shawrite(data, len << 3, state);
87 result = (char *) shadigest(state);
88 len = shadsize(state);
91 result = shahex(state);
93 result = shabase64(state);
94 ST(0) = sv_2mortal(newSVpv(result, len));
101 Digest::SHA::hmac_sha1 = 0
102 Digest::SHA::hmac_sha1_hex = 1
103 Digest::SHA::hmac_sha1_base64 = 2
104 Digest::SHA::hmac_sha224 = 3
105 Digest::SHA::hmac_sha224_hex = 4
106 Digest::SHA::hmac_sha224_base64 = 5
107 Digest::SHA::hmac_sha256 = 6
108 Digest::SHA::hmac_sha256_hex = 7
109 Digest::SHA::hmac_sha256_base64 = 8
110 Digest::SHA::hmac_sha384 = 9
111 Digest::SHA::hmac_sha384_hex = 10
112 Digest::SHA::hmac_sha384_base64 = 11
113 Digest::SHA::hmac_sha512 = 12
114 Digest::SHA::hmac_sha512_hex = 13
115 Digest::SHA::hmac_sha512_base64 = 14
124 key = (unsigned char *) (SvPV(ST(items-1), len));
125 if ((state = hmacopen(ix2alg[ix], key, len)) == NULL)
127 for (i = 0; i < items - 1; i++) {
128 data = (unsigned char *) (SvPV(ST(i), len));
129 hmacwrite(data, len << 3, state);
134 result = (char *) hmacdigest(state);
135 len = shadsize(state->osha);
137 else if (ix % 3 == 1)
138 result = hmachex(state);
140 result = hmacbase64(state);
141 ST(0) = sv_2mortal(newSVpv(result, len));
149 Digest::SHA::hashsize = 0
150 Digest::SHA::algorithm = 1
155 state = INT2PTR(SHA *, SvIV(SvRV(SvRV(self))));
156 result = shadsize(state) << 3;
157 if (ix == 1 && result == 160)
159 ST(0) = sv_2mortal(newSViv(result));
171 state = INT2PTR(SHA *, SvIV(SvRV(SvRV(self))));
172 for (i = 1; i < items; i++) {
173 data = (unsigned char *) (SvPV(ST(i), len));
174 shawrite(data, len << 3, state);
182 Digest::SHA::digest = 0
183 Digest::SHA::Hexdigest = 1
184 Digest::SHA::B64digest = 2
190 state = INT2PTR(SHA *, SvIV(SvRV(SvRV(self))));
194 result = (char *) shadigest(state);
195 len = shadsize(state);
198 result = shahex(state);
200 result = shabase64(state);
201 ST(0) = sv_2mortal(newSVpv(result, len));