emoney: Add Thinca authentication card stuff #35

Open
Haruka wants to merge 5 commits from Haruka/segatools:thinca_auth into develop
Contributor

This PR adds everything that's needed on the segatools side to add E-Money support regarding Thinca authentication cards.

I've also included set-up documentation (with a network side bonus which was as far as I could figure out so far, but I'm pretty certain no more changes to segatools will be needed)

Due to the nature of a custom protcol called TCAP that Thinca uses for networking (see docs), I can't fully test that everything works as I haven't yet bothered to figure that protocol out.

Tested with both APMv3 and FGO.

https://puu.sh/KeqVj/ccf4bcccbb.png

This PR adds everything that's needed on the segatools side to add E-Money support regarding Thinca authentication cards. I've also included set-up documentation (with a network side bonus which was as far as I could figure out so far, but I'm pretty certain no more changes to segatools will be needed) Due to the nature of a custom protcol called TCAP that Thinca uses for networking (see docs), I can't fully test that everything works as I haven't yet bothered to figure that protocol out. Tested with both APMv3 and FGO. ![https://puu.sh/KeqVj/ccf4bcccbb.png](https://puu.sh/KeqVj/ccf4bcccbb.png)
Haruka added 1 commit 2024-09-06 13:37:19 +00:00
Dniel97 requested changes 2024-09-09 20:51:05 +00:00
Dniel97 left a comment
Owner

Hello,

thanks again for an awesome PR! I'm currently still testing and verifying your PR but I have some small improvements/thoughts on your PR :)

Let me know what you think about them!

Hello, thanks again for an awesome PR! I'm currently still testing and verifying your PR but I have some small improvements/thoughts on your PR :) Let me know what you think about them!
doc/emoney.txt Outdated
@ -0,0 +1,185 @@
E-Money Authentication Procedure
Owner

Would it be possible to format this file as MarkDown (.md) instead of .txt, this would greatly improve readability?

Would it be possible to format this file as MarkDown (.md) instead of .txt, this would greatly improve readability?
Author
Contributor

Can do, I just usually write everything as text files in my repo because I am really not a fan of markdown syntax lmao

Can do, I just usually write everything as text files in my repo because I am really not a fan of markdown syntax lmao
Haruka marked this conversation as resolved
doc/emoney.txt Outdated
@ -0,0 +7,4 @@
New-Item 'HKLM:\Software\TFPaymentService' -Force | Out-Null
$acl = Get-Acl HKLM:\SOFTWARE\TFPaymentService
$rule = New-Object System.Security.AccessControl.RegistryAccessRule($env:username, "FullControl", "ContainerInherit,ObjectInherit", "None", "Allow")
Owner

Would it be possible to add an registry hook to segatools for that key?

Would it be possible to add an registry hook to segatools for that key?
Author
Contributor

can do

can do
Haruka marked this conversation as resolved
doc/emoney.txt Outdated
@ -0,0 +13,4 @@
2) Obtain the 64 byte long authentication card encryption key and the 32 byte long static authentication card ID. amdaemon.exe holds the secrets.
3) Get this java file, insert the ID and key, probably edit the passphrase and compile+run to generate authcard.bin: https://gist.github.com/akechi-haruka/a506184638e695a04eabe8cb53f62c36
Owner

Maybe a Python script included in this PR would be more useful than a java file on a gist

Maybe a Python script included in this PR would be more useful than a java file on a gist
Author
Contributor

I know no python, the best I can do is PHP lmao

Can modify it slightly that the keys are taken as parameter and specify to simply download the file somewhere and then run "javac emoney.java && java emoney" (no external deps)

I know no python, the best I can do is PHP lmao Can modify it slightly that the keys are taken as parameter and specify to simply download the file somewhere and then run "javac emoney.java && java emoney" (no external deps)
Dniel97 marked this conversation as resolved
doc/emoney.txt Outdated
@ -0,0 +19,4 @@
5) Check tfps-res-pro\env.json for your game. If it contains a "use_proxy: true" statement, add "proxy_flag=3" under [aime]
6) Replace the two URLs in tfps-res-pro\resource.xml to your servers'. This is to ensure the Host header will match the certificate's.
Owner

This is not needed as the corresponding URLS should be properly hooked:

hr = dns_hook_push(L"tasms-api-basis.thincacloud.com", cfg->startup);

This is not needed as the corresponding URLS should be properly hooked: https://gitea.tendokyu.moe/Dniel97/segatools/src/commit/9c66488906f4ebbbb1beb9070734a39be123c689/platform/dns.c#L93
Author
Contributor

Okay I missed that, but that definetly doesn't seem to work for me for some reason

I actually have never looked into why, I only know that it's supposed to use getaddrinfo though.

Okay I missed that, but that definetly doesn't seem to work for me for some reason I actually have never looked into why, I only know that it's supposed to use getaddrinfo though.
Owner

I was only able to test AimePay which used winhttp and worked correctly, it could well be that thinca uses something different.

I was only able to test AimePay which used winhttp and worked correctly, it could well be that thinca uses something different.
Author
Contributor

thincahttpclient.dll is just dynamically loaded, so that would be fixed with commit 6dacc8ba, however, this runs into several HTTPS failures. Host name to certificate mismatch, as well as that most servers can't really run HTTPS client-auth on port 443 (as that would block game services itself)

Granted, you could do the whole dance with self-signed certificates but that's really overkill. Maybe a file redirection hook or something might be smarter.

thincahttpclient.dll is just dynamically loaded, so that would be fixed with commit 6dacc8ba, however, this runs into several HTTPS failures. Host name to certificate mismatch, as well as that most servers can't really run HTTPS client-auth on port 443 (as that would block game services itself) Granted, you could do the whole dance with self-signed certificates but that's really overkill. Maybe a file redirection hook or something might be smarter.
Dniel97 marked this conversation as resolved
Dniel97 added the
enhancement
label 2024-09-09 20:51:18 +00:00
Haruka added 2 commits 2024-09-11 12:13:05 +00:00
Haruka added 1 commit 2024-09-11 13:11:43 +00:00
Haruka added 1 commit 2024-09-11 13:37:01 +00:00
This pull request can be merged automatically.
This branch is out-of-date with the base branch
You are not authorized to merge this pull request.

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u thinca_auth:Haruka-thinca_auth
git checkout Haruka-thinca_auth
Sign in to join this conversation.
No reviewers
No Milestone
No Assignees
2 Participants
Notifications
Due Date
The due date is invalid or out of range. Please use the format 'yyyy-mm-dd'.

No due date set.

Dependencies

No dependencies set.

Reference: Dniel97/segatools#35
No description provided.