viff

changeset 1074:64052822e204

Repeat random sharing in byte_sub if masked byte is zero.
author Marcel Keller <mkeller@cs.au.dk>
date Sun, 11 Jan 2009 13:55:47 +0100
parents 936ce049980f
children 249bba0f9ad0
files viff/aes.py
diffstat 1 files changed, 14 insertions(+), 4 deletions(-) [+]
line diff
     1.1 --- a/viff/aes.py	Fri Jan 09 15:29:40 2009 +0100
     1.2 +++ b/viff/aes.py	Sun Jan 11 13:55:47 2009 +0100
     1.3 @@ -89,10 +89,20 @@
     1.4                  # b == 1 if byte is 0, b == 0 else
     1.5                  b = bits[0]
     1.6  
     1.7 -                r = self.runtime.prss_share_random(GF256)
     1.8 -                c = self.runtime.open((byte + b) * r)
     1.9 -                
    1.10 -                c.addCallback(lambda c: ~c)
    1.11 +                r = Share(self.runtime, GF256)
    1.12 +                c = Share(self.runtime, GF256)
    1.13 +
    1.14 +                def get_masked_byte(c_opened, r_related, c, r, byte):
    1.15 +                    if (c_opened == 0):
    1.16 +                        r_trial = self.runtime.prss_share_random(GF256)
    1.17 +                        c_trial = self.runtime.open((byte + b) * r_trial)
    1.18 +                        c_trial.addCallback(get_masked_byte, r_trial,
    1.19 +                                            c, r, byte)
    1.20 +                    else:
    1.21 +                        r_related.addCallback(r.callback)
    1.22 +                        c.callback(~c_opened)
    1.23 +
    1.24 +                get_masked_byte(0, None, c, r, byte)
    1.25                  inverted_byte = c * r - b
    1.26  
    1.27                  bits = bit_decompose(inverted_byte)