|
12 | 12 | -module(rsa_pss). |
13 | 13 |
|
14 | 14 | -include_lib("public_key/include/public_key.hrl"). |
| 15 | +-include("include/hb.hrl"). |
15 | 16 |
|
16 | 17 | %% API |
17 | 18 | -export([sign/3]). |
@@ -88,7 +89,7 @@ verify({digest, Digest}, DigestType, Signature, PublicKey=#'RSAPublicKey'{modulu |
88 | 89 | PrivateByteSize = (PublicBitSize + 7) div 8, |
89 | 90 | PublicByteSize = int_to_byte_size(N), |
90 | 91 | SignatureSize = byte_size(Signature), |
91 | | - case PublicByteSize =:= SignatureSize of |
| 92 | + Ret = case PublicByteSize =:= SignatureSize of |
92 | 93 | true -> |
93 | 94 | SignatureNumber = binary:decode_unsigned(Signature, big), |
94 | 95 | case SignatureNumber >= 0 andalso SignatureNumber < N of |
@@ -124,7 +125,8 @@ verify({digest, Digest}, DigestType, Signature, PublicKey=#'RSAPublicKey'{modulu |
124 | 125 | end; |
125 | 126 | false -> |
126 | 127 | false |
127 | | - end. |
| 128 | + end, |
| 129 | + Ret. |
128 | 130 |
|
129 | 131 | verify_legacy(Message, DigestType, Signature, PublicKey) when is_binary(Message) -> |
130 | 132 | verify_legacy({digest, crypto:hash(DigestType, Message)}, DigestType, Signature, PublicKey); |
@@ -185,16 +187,9 @@ ep(B, #'RSAPublicKey'{modulus=N, publicExponent=E}) -> |
185 | 187 | crypto:mod_pow(B, E, N). |
186 | 188 |
|
187 | 189 | %% @private |
188 | | -int_to_bit_size(I) -> |
189 | | - int_to_bit_size(I, 0). |
| 190 | +int_to_bit_size(I) -> |
| 191 | + bit_size(binary:encode_unsigned(I)). |
190 | 192 |
|
191 | | -%% @private |
192 | | -int_to_bit_size(0, B) -> |
193 | | - B; |
194 | | -int_to_bit_size(I, B) -> |
195 | | - int_to_bit_size(I bsr 1, B + 1). |
196 | | - |
197 | | -%% @private |
198 | 193 | int_to_byte_size(I) -> |
199 | 194 | int_to_byte_size(I, 0). |
200 | 195 |
|
|
0 commit comments