Skip to content

Commit 02c0e03

Browse files
committed
fix: make rsa_pss int_to_bit_size more efficient
1 parent f9be075 commit 02c0e03

File tree

1 file changed

+3
-9
lines changed

1 file changed

+3
-9
lines changed

src/rsa_pss.erl

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
-module(rsa_pss).
1313

1414
-include_lib("public_key/include/public_key.hrl").
15+
-include("include/hb.hrl").
1516

1617
%% API
1718
-export([sign/3]).
@@ -185,16 +186,9 @@ ep(B, #'RSAPublicKey'{modulus=N, publicExponent=E}) ->
185186
crypto:mod_pow(B, E, N).
186187

187188
%% @private
188-
int_to_bit_size(I) ->
189-
int_to_bit_size(I, 0).
189+
int_to_bit_size(I) ->
190+
bit_size(binary:encode_unsigned(I)).
190191

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
198192
int_to_byte_size(I) ->
199193
int_to_byte_size(I, 0).
200194

0 commit comments

Comments
 (0)