1*7f2fe78bSCy Schubertimport base64 2*7f2fe78bSCy Schubertimport socket 3*7f2fe78bSCy Schubertfrom k5test import * 4*7f2fe78bSCy Schubert 5*7f2fe78bSCy Schubertrealm = K5Realm() 6*7f2fe78bSCy Schubert 7*7f2fe78bSCy Schubert# Send encodings that are invalid KDC-REQs, but pass krb5_is_as_req() 8*7f2fe78bSCy Schubert# and krb5_is_tgs_req(), to make sure that the KDC recovers correctly 9*7f2fe78bSCy Schubert# from failures in decode_krb5_as_req() and decode_krb5_tgs_req(). 10*7f2fe78bSCy Schubert 11*7f2fe78bSCy Schuberts = socket.socket(socket.AF_INET, socket.SOCK_DGRAM) 12*7f2fe78bSCy Schuberta = (hostname, realm.portbase) 13*7f2fe78bSCy Schubert 14*7f2fe78bSCy Schubert 15*7f2fe78bSCy Schubert# Bogus AS-REQ 16*7f2fe78bSCy Schubert 17*7f2fe78bSCy Schubertx1 = base64.b16decode('6AFF') 18*7f2fe78bSCy Schuberts.sendto(x1, a) 19*7f2fe78bSCy Schubert 20*7f2fe78bSCy Schubert# Make sure kinit still works. 21*7f2fe78bSCy Schubert 22*7f2fe78bSCy Schubertrealm.kinit(realm.user_princ, password('user')) 23*7f2fe78bSCy Schubert 24*7f2fe78bSCy Schubert# Bogus TGS-REQ 25*7f2fe78bSCy Schubert 26*7f2fe78bSCy Schubertx2 = base64.b16decode('6CFF') 27*7f2fe78bSCy Schuberts.sendto(x2, a) 28*7f2fe78bSCy Schubert 29*7f2fe78bSCy Schubert# Make sure kinit still works. 30*7f2fe78bSCy Schubert 31*7f2fe78bSCy Schubertrealm.kinit(realm.user_princ, password('user')) 32*7f2fe78bSCy Schubert 33*7f2fe78bSCy Schubert# Not a KDC-REQ, even a little bit 34*7f2fe78bSCy Schubert 35*7f2fe78bSCy Schubertx3 = base64.b16decode('FFFF') 36*7f2fe78bSCy Schuberts.sendto(x3, a) 37*7f2fe78bSCy Schubert 38*7f2fe78bSCy Schubert# Make sure kinit still works. 39*7f2fe78bSCy Schubert 40*7f2fe78bSCy Schubertrealm.kinit(realm.user_princ, password('user')) 41*7f2fe78bSCy Schubert 42*7f2fe78bSCy Schubertsuccess('Bogus KDC-REQ test') 43