예제 #1
0
파일: test.py 프로젝트: sanyaade-iot/libscs
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
예제 #2
0
파일: modpyscs.py 프로젝트: babongo/libscs
 def err(self):
         
     return scs.err(self.s) 
예제 #3
0
파일: test.py 프로젝트: sanyaade-iot/libscs
# 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.'
예제 #4
0
    def err(self):

        return scs.err(self.s)