Esempio n. 1
0
def test(str):
    print 'input state: [', str, ']'

    ck = scs.encode(s, str, len(str))
    if ck is None:
        print '[err]: ', scs.err(s)
        raise Exception
        
    print 'encoded cookie: [', ck, ']'

    st = scs.decode(s, ck)
    if st is None:
        print '[err]: ', scs.err(s)
        raise Exception

    print 'decoded state: [', st, ']'

    if st != str:
        print '[err] input state different from decoded state!'
        raise Exception
Esempio n. 2
0
 def err(self):
         
     return scs.err(self.s) 
Esempio n. 3
0
# Run tests
s = None

try:
    # initialise SCS parameters
    s = scs.init(
            'tid', 
            0, 
            'k', 
            'hk', 
            0, 
            60);    #sessions may last at most 60 seconds 

    if s is None:
        print '[err]: ', scs.err(s)
        raise Exception

    # basic encoding/decoding tests
    test('some cool state 1')
    test('some other state 2')

    # test key refresh
    scs.refresh_keyset(s, 'tid2', 'k2', 'hk2')

    test('some other cool state 3 after key refresh')

    # cleanup
    scs.term(s)

    print 'All tests passed.'
Esempio n. 4
0
    def err(self):

        return scs.err(self.s)