Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Using OP instead of OPC #182

Open
b3c3ll opened this issue Jan 13, 2024 · 1 comment
Open

Using OP instead of OPC #182

b3c3ll opened this issue Jan 13, 2024 · 1 comment

Comments

@b3c3ll
Copy link

b3c3ll commented Jan 13, 2024

Hi
Thanks for your great repo!
I was wondering if it is possible to use OP instead of OP for AUC authentication?

Thanks
Best regards

@svinson1121
Copy link

I think PyHSS only supports OPC

you can calculate the OPC from the OP and KI (OPC = AES128(ki,OP) XOR OP)

I did something in python to do this:


from Crypto.Cipher import AES
import binascii

def calculate_opc(ki, op):
# Convert the Ki and OP values from hex strings to byte arrays
ki_bytes = binascii.unhexlify(ki)
op_bytes = binascii.unhexlify(op)

# Create a new AES object with the Ki value as the key
aes = AES.new(ki_bytes, AES.MODE_ECB)

# Use the AES object to encrypt the OP value
encrypted_op = aes.encrypt(op_bytes)

# XOR the encrypted OP value with the original OP value to get the OPC value
opc = bytearray(len(op_bytes))
for i in range(len(op_bytes)):
    opc[i] = encrypted_op[i] ^ op_bytes[i]

# Convert the OPC value to a hex string and return it
return binascii.hexlify(opc).decode('utf-8')

ki = (input('Enter Ki: '))
op = (input('Enter Op: '))
opc = calculate_opc(ki, op)
print('OPc: ' + opc)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants