def smptest(secret, sock, is_server): global axolotl # Create an SMP object with the calculated secret smp = SMP(secret) if is_server: # Do the SMP protocol buffer = sock.recv(2439, socket.MSG_WAITALL) padlength = ord(buffer[-1:]) buffer = axolotl.decrypt(buffer[:-padlength]) buffer = smp.step2(buffer) buffer = axolotl.encrypt(buffer) padlength = 4539-len(buffer) buffer = buffer+padlength*chr(padlength) # pad to fixed length sock.send(buffer) buffer = sock.recv(3469, socket.MSG_WAITALL) padlength = ord(buffer[-1:]) buffer = axolotl.decrypt(buffer[:-padlength]) buffer = smp.step4(buffer) buffer = axolotl.encrypt(buffer) padlength = 1369-len(buffer) buffer = buffer+padlength*chr(padlength) # pad to fixed length sock.send(buffer) else: # Do the SMP protocol buffer = smp.step1() buffer = axolotl.encrypt(buffer) padlength = 2439-len(buffer) buffer = buffer+padlength*chr(padlength) # pad to fixed length sock.send(buffer) buffer = sock.recv(4539, socket.MSG_WAITALL) padlength = ord(buffer[-1:]) buffer = axolotl.decrypt(buffer[:-padlength]) buffer = smp.step3(buffer) buffer = axolotl.encrypt(buffer) padlength = 3469-len(buffer) buffer = buffer+padlength*chr(padlength) # pad to fixed length sock.send(buffer) buffer = sock.recv(1369, socket.MSG_WAITALL) padlength = ord(buffer[-1:]) buffer = axolotl.decrypt(buffer[:-padlength]) smp.step5(buffer) # Check if the secrets match if smp.match: print 'Secrets Match!' sleep(1) smp_match = True else: print 'Secrets DO NOT Match!' smp_match = False return smp_match
def smptest(secret, sock, is_server): global axolotl # Create an SMP object with the calculated secret smp = SMP(secret) if is_server: # Do the SMP protocol buffer = sock.recv(2439, socket.MSG_WAITALL) padlength = ord(buffer[-1:]) buffer = axolotl.decrypt(buffer[:-padlength]) buffer = smp.step2(buffer) buffer = axolotl.encrypt(buffer) padlength = 4539 - len(buffer) buffer = buffer + padlength * chr(padlength) # pad to fixed length sock.send(buffer) buffer = sock.recv(3469, socket.MSG_WAITALL) padlength = ord(buffer[-1:]) buffer = axolotl.decrypt(buffer[:-padlength]) buffer = smp.step4(buffer) buffer = axolotl.encrypt(buffer) padlength = 1369 - len(buffer) buffer = buffer + padlength * chr(padlength) # pad to fixed length sock.send(buffer) else: # Do the SMP protocol buffer = smp.step1() buffer = axolotl.encrypt(buffer) padlength = 2439 - len(buffer) buffer = buffer + padlength * chr(padlength) # pad to fixed length sock.send(buffer) buffer = sock.recv(4539, socket.MSG_WAITALL) padlength = ord(buffer[-1:]) buffer = axolotl.decrypt(buffer[:-padlength]) buffer = smp.step3(buffer) buffer = axolotl.encrypt(buffer) padlength = 3469 - len(buffer) buffer = buffer + padlength * chr(padlength) # pad to fixed length sock.send(buffer) buffer = sock.recv(1369, socket.MSG_WAITALL) padlength = ord(buffer[-1:]) buffer = axolotl.decrypt(buffer[:-padlength]) smp.step5(buffer) # Check if the secrets match if smp.match: print 'Secrets Match!' sleep(1) smp_match = True else: print 'Secrets DO NOT Match!' smp_match = False return smp_match
def smptest(secret, sock, is_server): # Create an SMP object with the calculated secret smp = SMP(secret) if is_server: # Do the SMP protocol buffer = a.decrypt(sock.recv(2311, socket.MSG_WAITALL)) buffer = smp.step2(buffer) buffer = a.encrypt(buffer) buffer = buffer+(4412-len(buffer))*b'\x00' # pad to fixed length sock.send(buffer) buffer = a.decrypt(sock.recv(3345, socket.MSG_WAITALL)) buffer = smp.step4(buffer) buffer = a.encrypt(buffer) buffer = buffer+(1243-len(buffer))*b'\x00' # pad to fixed length sock.send(buffer) else: # Do the SMP protocol buffer = smp.step1() buffer = a.encrypt(buffer) buffer = buffer+(2311-len(buffer))*b'\x00' # pad to fixed length sock.send(buffer) buffer = a.decrypt(sock.recv(4412, socket.MSG_WAITALL)) buffer = smp.step3(buffer) buffer = a.encrypt(buffer) buffer = buffer+(3345-len(buffer))*b'\x00' # pad to fixed length sock.send(buffer) buffer = a.decrypt(sock.recv(1243, socket.MSG_WAITALL)) smp.step5(buffer) # Check if the secrets match if smp.match: writeToScreen(' Secrets Match!') #chat_window.insert(tk.END, 'Secrets Match!') smp_match = True else: writeToScreen(' Secrets DO NOT Match!') #chat_window.insert(tk.END, 'Secrets DO NOT Match!') smp_match = False return smp_match