<s> import sys <EOL> import unittest <EOL> import pyhsm <EOL> import test_common <EOL> class TestBuffer ( test_common . YHSM_TestCase ) : <EOL> def setUp ( self ) : <EOL> test_common . YHSM_TestCase . setUp ( self ) <EOL> def test_load_random ( self ) : <EOL> """<STR_LIT>""" <EOL> nonce = "<STR_LIT>" <EOL> key_handle = <NUM_LIT> <EOL> self . hsm . load_random ( <NUM_LIT:16> ) <EOL> aead1 = self . hsm . generate_aead ( nonce , key_handle ) <EOL> self . hsm . load_random ( <NUM_LIT:16> ) <EOL> aead2 = self . hsm . generate_aead ( nonce , key_handle ) <EOL> self . assertNotEqual ( aead1 . data , aead2 . data ) <EOL> def test_would_overflow_buffer ( self ) : <EOL> """<STR_LIT>""" <EOL> nonce = "<STR_LIT>" <EOL> key_handle = <NUM_LIT> <EOL> self . assertEqual ( <NUM_LIT:64> , self . hsm . load_random ( <NUM_LIT:16> , offset = pyhsm . defines . YSM_DATA_BUF_SIZE - <NUM_LIT:8> ) ) <EOL> self . assertEqual ( <NUM_LIT:16> , self . hsm . load_random ( <NUM_LIT:16> , offset = <NUM_LIT:0> ) ) <EOL> self . assertEqual ( <NUM_LIT> , self . hsm . load_random ( <NUM_LIT:1> , offset = <NUM_LIT:16> ) ) <EOL> self . assertEqual ( <NUM_LIT> , self . hsm . load_random ( <NUM_LIT:7> , offset = <NUM_LIT:10> ) ) <EOL> self . assertEqual ( <NUM_LIT> , self . hsm . load_random ( <NUM_LIT:1> , offset = <NUM_LIT> ) ) <EOL> self . assertEqual ( <NUM_LIT:64> , self . hsm . load_random ( <NUM_LIT> , offset = <NUM_LIT> ) ) <EOL> def test_load_data ( self ) : <EOL> """<STR_LIT>""" <EOL> c1 = self . hsm . load_data ( '<STR_LIT>' , offset = <NUM_LIT:0> ) <EOL> self . assertEqual ( c1 , <NUM_LIT:4> ) <EOL> c2 = self . hsm . load_data ( '<STR_LIT>' , offset = <NUM_LIT:3> ) <EOL> self . assertEqual ( c2 , <NUM_LIT:6> ) <EOL> c3 = self . hsm . load_data ( '<STR_LIT>' , offset = <NUM_LIT:3> ) <EOL> self . assertEqual ( c3 , <NUM_LIT:9> ) <EOL> nonce = "<STR_LIT>" <EOL> key_handle = <NUM_LIT> <EOL> aead = self . hsm . generate_aead ( nonce , key_handle ) <EOL> self . assertEqual ( aead . data . encode ( '<STR_LIT>' ) , '<STR_LIT>' ) </s>
