summaryrefslogtreecommitdiff
path: root/lib/srp/util.rb
diff options
context:
space:
mode:
authorAzul <azul@leap.se>2012-07-26 10:58:28 +0200
committerAzul <azul@leap.se>2012-07-26 10:58:28 +0200
commit26580be7f9b557ed8136aa11c7b4e7b96f9c86eb (patch)
tree69d51298f042862e2e9c1aec3033bab7d101e3a1 /lib/srp/util.rb
parent7de7a78668a83eaab58597ce655ba613d4b477fb (diff)
both sides calculate their own u
Diffstat (limited to 'lib/srp/util.rb')
-rw-r--r--lib/srp/util.rb9
1 files changed, 9 insertions, 0 deletions
diff --git a/lib/srp/util.rb b/lib/srp/util.rb
index efbecaa..577977e 100644
--- a/lib/srp/util.rb
+++ b/lib/srp/util.rb
@@ -66,6 +66,15 @@ d15dc7d7b46154d6b6ce8ef4ad69b15d4982559b297bcf1885c529f566660e5
sha256_str(hashin).hex
end
+ def calculate_u(aa, bb, n)
+ nlen = 2 * ((('%x' % [n]).length * 4 + 7) >> 3)
+ aahex = '%x' % [aa]
+ bbhex = '%x' % [bb]
+ return sha256_str("%x%x" % [aa, bb]).hex
+ hashin = '0' * (nlen - aahex.length) + aahex \
+ + '0' * (nlen - bbhex.length) + bbhex
+ sha256_str(hashin).hex
+ end
end
end