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

psk based TLS with openssl #231

Closed
tenderitaf opened this issue Jun 27, 2017 · 4 comments
Closed

psk based TLS with openssl #231

tenderitaf opened this issue Jun 27, 2017 · 4 comments

Comments

@tenderitaf
Copy link

Hi,

I'm trying to use a conscrypt based client to establish a TLS tunnel using psk.

I was able to access pskKeyManager via reflection (as you guys did in your unit test).

The TLS tunnel fails, here is the error message I have at openssl level :

SSL routines:SSL3_GET_RECORD:decryption failed or bad record mac:s3_pkt.c:487

I'm suspecting this area of the code ,

`protected SecretKey getKey( String identityHint, String identity, Socket socket) {
	return new SecretKeySpec("afakekey".getBytes(), "RAW");
}`

I don't know what to use as algorithm in the second argument.

here is my openssl test server configuration
openssl s_server \ -psk 1A1A1A1A1A1A1A1A1A1A1A1A1A1A1A1A \ -psk_hint Client_identity\ -cipher PSK-AES256-CBC-SHA \ -debug -state -nocert -accept 10443 -tls1 -www

Any hint ??
Thanks in advance

@davidben
Copy link
Contributor

PSK means "pre-shared key" which means that it's on you to ensure that both ends have the same pre-shared key. It sounds like you are using "afakekey" on one side and 1A1A1A1A1A1A1A1A1A1A1A1A1A1A1A1A on the other, which is naturally not going to work.

Of course, neither "afakekey" nor 1A1A1A1A1A1A1A1A1A1A1A1A1A1A1A1A are acceptable keys outside a test environment, as this key must be secret. Embedding a key into your client binary would also not be acceptable in most circumstances as anyone who can download the binary can just extract it. PSK is very rarely what you actually want.

@tenderitaf
Copy link
Author

Hi david,
My bad, I'm using "1A1A1A1A1A1A1A1A1A1A1A1A1A1A1A1A" in both sides. I'm using this setup just to test my code first. the way to get and store the keys is totally different.

@davidben
Copy link
Contributor

OpenSSL appears to decode your argument as hex whereas String.getBytes won't. Try new byte[]{ 0x1a, 0x1a, 0x1a, (etc)}.

@tenderitaf
Copy link
Author

Thanks much, this solved my issue.

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