-
Notifications
You must be signed in to change notification settings - Fork 16
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
Can not find smartcard.System module #2
Comments
Hi, |
Thank you. I execute command pip3 install pyscard, there are some errors: root@ubuntu:~/nwu_emulator# pip3 install pyscard Failed building wheel for pyscard
Command "/usr/bin/python3 -u -c "import setuptools, tokenize;file='/tmp/pip-build-n9cvw4ya/pyscard/setup.py';f=getattr(tokenize, 'open', open)(file);code=f.read().replace('\r\n', '\n');f.close();exec(compile(code, file, 'exec'))" install --record /tmp/pip-vol9itgd-record/install-record.txt --single-version-externally-managed --compile" failed with error code 1 in /tmp/pip-build-n9cvw4ya/pyscard/ |
I don't know what that issue is... fabricio@free5gc:~$ python3
fabricio@free5gc:~$ pip3 install pyscard fabricio@free5gc:~$ python3
|
What does os your vm use? Can you show me some information, such as printing uname -a, lsb_release -a? |
Hi, fabricio@free5gc: or this one: fabricio@ubuntu: |
Okay. Can you print apt list --installed and dpkg -l? My system is ubuntu,too. So I think it may be lack of some installed packages. ubuntu@kvmhostrack45row34: |
fabricio@free5gc: |
If no Modem/SmartCard Reader/HTTPS Server then a default CK, IK and RES will be used (check corresponding variables inside the code). How should I modify code in that case? |
In the nwu_emulator.py file, starting in line 94 you have the default values, and in line 103 to 105 you have the ck, ik and res. You can change them in the file. DEFAULT_CK = '0123456789ABCDEF0123456789ABCDEF' |
Thanks for your patience. I want to know if I don't need to import smartcard.System module and smartcard.util module when there is no Modem/SmartCard Reader/HTTPS Server. |
You have two options if you remove the import of the smartcard module (or do a try/except in the import):
|
I know the Ki, OP/OPC of the card. So I commented these modules in the code. Can you tell me which other modules do not need to be imported? How do I modify the code? Now another issue is CryptoMobile.Milenage module: |
Can you give me the printout of pip3 list and pip list? Thanks! |
CryptoMobile Module: https://github.com/P1sec/CryptoMobile ~$ pip3 list apturl 0.5.2 ~$ pip list apturl 0.5.2 |
Thank you. I run the script, then it returns error: ubuntu@KVMHostRack45Row36:~/n3iwf-sim$ sudo python3 nwu_emulator.py -a inet1.mnc005.mcc450.gprs -d 11.11.48.200 -M 450 -N 05 -I 450051111000002 -K 00112233445566778899AABBCCDDEEFF -P 00112233445566778899AABBCCDDEEFF -s 10.46.205.10 STATE 1:Traceback (most recent call last): TypeError: parameters() missing 1 required positional argument: 'backend' |
It looks like you are using an old version of the cryptography module, where the call parameters() still needs an argument.
In recent versions that argument became optional, according to what I've found in this post.Check the latest comments. https://stackoverflow.com/questions/65987293/typeerror-load-pem-private-key-missing-1-required-positional-argument-backe
You can check your version with python3 -m jwt.help
In my VM i have this:
#python3 -m jwt.help
{
"cryptography": {
"version": "3.2.1"
},
"implementation": {
"name": "CPython",
"version": "3.8.10"
},
"platform": {
"release": "5.11.0-43-generic",
"system": "Linux"
},
"pyjwt": {
"version": "1.7.1"
}
}
Try to update this module with the following command:
$ python3 -m pip install --upgrade pyjwt[crypto]
Hope this helps
… No dia 29/01/2022, às 03:08, casa-hyx ***@***.***> escreveu:
Thank you. I run the script, then it returns error:
***@***.***:~/n3iwf-sim$ sudo python3 nwu_emulator.py -a inet1.mnc005.mcc450.gprs -d 11.11.48.200 -M 450 -N 05 -I 450051111000002 -K 00112233445566778899AABBCCDDEEFF -P 00112233445566778899AABBCCDDEEFF -s 10.46.205.10
INTERFACE_TYPE 1
STATE 1:
Traceback (most recent call last):
File "nwu_emulator.py", line 5018, in
main()
File "nwu_emulator.py", line 5013, in main
a.start_ike()
File "nwu_emulator.py", line 4244, in start_ike
if self.interface_type == NWU: self.start_ike_nwu()
File "nwu_emulator.py", line 4257, in start_ike_nwu
result,info = self.state_1()
File "nwu_emulator.py", line 2701, in state_1
packet = self.create_IKE_SA_INIT(retry, cookie)
File "nwu_emulator.py", line 2501, in create_IKE_SA_INIT
payload += self.encode_generic_payload_header(KE,0,self.encode_payload_type_sa(self.sa_list))
File "nwu_emulator.py", line 1402, in encode_payload_type_sa
self.dh_create_private_key_and_public_bytes(self.iana_diffie_hellman.get(transform_id))
File "nwu_emulator.py", line 834, in dh_create_private_key_and_public_bytes
parameters = self.pn.parameters()
TypeError: parameters() missing 1 required positional argument: 'backend'
—
Reply to this email directly, view it on GitHub, or unsubscribe.
You are receiving this because you commented.
|
Thank you. I run the script and it returns errors: ubuntu@KVMHostRack45Row36:~/n3iwf-sim$ sudo python3 nwu_emulator.py -a inet1.mnc005.mcc450.gprs -d 11.11.48.200 -M 450 -N 05 -I 450051111000002 -K 00112233445566778899AABBCCDDEEFF -P 00112233445566778899AABBCCDDEEFF -s 10.46.205.10 STATE 1:NAT SOURCE 48c2f1b393e8c880130a510174ed79d8b3ff0e8e Received IKE message decoded: From the trace, N3iwf reply ike_sa_init response with "Payload: Notify (41) - NO_PROPOSAL_CHOSEN". |
Do you know what algorithms the N3IWF supports? Can yo change the configuration on the N3IWF? But for now check the sa_list variable, since N3IWF is basically saying that your 3 proposals do not match with any server acceptable proposal. |
This is the configuration of algorithms in N3iwf yaml file.
ike:
encriptionAlgorithms:
- "null"
- aes128
integritycheckAlgorithms:
- sha1
- md5
dHGroup:
- modp768
- modp1024
- modp2048
reKeyPeriod: 0
signalingIPSecSA:
encriptionAlgorithms:
- "null"
- aes128
integritycheckAlgorithms:
- sha1
- md5
dHGroup:
- modp768
- modp1024
- modp2048
reKeyPeriod: 0
Can you modify the script to send only one proposal by ike_sa_init like this?
Payload: Proposal (2) # 1
Next payload: NONE / No Next Payload (0)
Reserved: 00
Payload length: 40
Proposal number: 1
Protocol ID: IKE (1)
SPI Size: 0
Proposal transforms: 4
Payload: Transform (3)
Next payload: Transform (3)
Reserved: 00
Payload length: 8
Transform Type: Encryption Algorithm (ENCR) (1)
Reserved: 00
Transform ID (ENCR): ENCR_NULL (11)
Payload: Transform (3)
Next payload: Transform (3)
Reserved: 00
Payload length: 8
Transform Type: Integrity Algorithm (INTEG) (3)
Reserved: 00
Transform ID (INTEG): AUTH_HMAC_SHA1_96 (2)
Payload: Transform (3)
Next payload: Transform (3)
Reserved: 00
Payload length: 8
Transform Type: Pseudo-random Function (PRF) (2)
Reserved: 00
Transform ID (PRF): PRF_HMAC_SHA1 (2)
Payload: Transform (3)
Next payload: NONE / No Next Payload (0)
Reserved: 00
Payload length: 8
Transform Type: Diffie-Hellman Group (D-H) (4)
Reserved: 00
Transform ID (D-H): Alternate 1024-bit MODP group (2)
heyongxin
From: Fabricio
Date: 2022-02-07 19:30
To: fasferraz/NWu-Non3GPP-5GC
CC: casa-hyx; Author
Subject: Re: [fasferraz/NWu-Non3GPP-5GC] Can not find smartcard.System module (Issue #2)
Do you know what algorithms the N3IWF supports? Can yo change the configuration on the N3IWF?
if not, you need to match the supported algorithms in the emulator.
That is done inside the code in the file nwu_emulator.py:
Check the sa_list variable and sa_list_child (for the child SA).
But for now check the sa_list variable, since N3IWF is basically saying that your 3 proposals do not match with any server acceptable proposal.
—
Reply to this email directly, view it on GitHub, or unsubscribe.
Triage notifications on the go with GitHub Mobile for iOS or Android.
You are receiving this because you authored the thread.Message ID: ***@***.***>
|
use this value for sa_list variable: sa_list = [ |
Thanks for your help. N3iwf can respond ike_sa_init normally.
Then simulator initiate an IKE_AUTH exchange by sending an IKE_AUTH request message.
The N3IWF cannot respond with an IKE_AUTH response message. There are some errors found in N3iwf logs:
Feb 8 06:07:53 04[ENC] <1> invalid ID_INITIATOR payload length, decryption failed?
Feb 8 06:07:53 04[ENC] <1> could not decrypt payloads
Feb 8 06:07:53 04[IKE] <1> message parsing failed
Feb 8 06:07:53 04[ENC] <1> added payload of type NOTIFY to message
Feb 8 06:07:53 04[IKE] <1> N3IWF RESPONDER IKE Message handler OUTGOING message.
I decrypt ike_auth initiator message in pcap and compare with previous trace file "landslide_ike_payload.txt".
I found there are many difference in payload of initiator.
heyongxin
From: Fabricio
Date: 2022-02-08 01:18
To: fasferraz/NWu-Non3GPP-5GC
CC: casa-hyx; Author
Subject: Re: [fasferraz/NWu-Non3GPP-5GC] Can not find smartcard.System module (Issue #2)
use this value for sa_list variable:
sa_list = [
[
[IKE,0],
[ENCR,ENCR_NULL],
[PRF,PRF_HMAC_SHA1],
[INTEG,AUTH_HMAC_SHA1_96],
[D_H,MODP_1024_bit]
]
]
—
Reply to this email directly, view it on GitHub, or unsubscribe.
Triage notifications on the go with GitHub Mobile for iOS or Android.
You are receiving this because you authored the thread.Message ID: ***@***.***>
|
can you share some traces? what is the n3iwf vendor? I only tested it with free5gc, which has several non compliant implementations... |
N3iwf belong to casa-systems company. Can you receive the attached from the last email?
何永信
From: Fabricio
Date: 2022-02-09 21:59
To: fasferraz/NWu-Non3GPP-5GC
CC: casa-hyx; Author
Subject: Re: [fasferraz/NWu-Non3GPP-5GC] Can not find smartcard.System module (Issue #2)
can you share some traces? what is the n3iwf vendor? I only tested it with free5gc, which has several non compliant implementations...
—
Reply to this email directly, view it on GitHub, or unsubscribe.
Triage notifications on the go with GitHub Mobile for iOS or Android.
You are receiving this because you authored the thread.Message ID: ***@***.***>
|
No i didn't receive any attached file. pleas send it to my email. It's in my profile page. |
Hi,
I have sent the all the trace log to your email address.
***@***.***
From: Fabricio
Date: 2022-02-10 00:11
To: fasferraz/NWu-Non3GPP-5GC
CC: casa-hyx; Author
Subject: Re: [fasferraz/NWu-Non3GPP-5GC] Can not find smartcard.System module (Issue #2)
No i didn't receive any attached file. pleas send it to my email. It's in my profile page.
—
Reply to this email directly, view it on GitHub, or unsubscribe.
Triage notifications on the go with GitHub Mobile for iOS or Android.
You are receiving this because you authored the thread.Message ID: ***@***.***>
|
As I run python3 nwu_emulator.py, system prompt ModuleNotFoundError: No module named 'smartcard.System'.
How can I load smartcard.System module?
The text was updated successfully, but these errors were encountered: