Skip to content

Commit

Permalink
Removed safebit stuff as it breaks in certain situations. Will look a…
Browse files Browse the repository at this point in the history
…t it later.
  • Loading branch information
sybrenstuvel committed Jul 10, 2011
1 parent 5f6d9e2 commit 3f8c551
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions rsa/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

import types

import rsa.common
#import rsa.common

def encrypt_int(message, ekey, n):
"""Encrypts a message using encryption key 'ekey', working modulo n"""
Expand All @@ -24,8 +24,8 @@ def encrypt_int(message, ekey, n):
raise OverflowError("The message %i is too long for n=%i" % (message, n))

#Note: Bit exponents start at zero (bit counts start at 1) this is correct
safebit = rsa.common.bit_size(n) - 2 # compute safe bit (MSB - 1)
message += (1 << safebit) # add safebit to ensure folding
# safebit = rsa.common.bit_size(n) - 2 # compute safe bit (MSB - 1)
# message += (1 << safebit) # add safebit to ensure folding

return pow(message, ekey, n)

Expand All @@ -35,8 +35,8 @@ def decrypt_int(cyphertext, dkey, n):

message = pow(cyphertext, dkey, n)

safebit = rsa.common.bit_size(n) - 2 # compute safe bit (MSB - 1)
message -= (1 << safebit) # remove safebit before decode
# safebit = rsa.common.bit_size(n) - 2 # compute safe bit (MSB - 1)
# message -= (1 << safebit) # remove safebit before decode

return message

0 comments on commit 3f8c551

Please sign in to comment.