fix login issue*
This commit is contained in:
60
test/crypto_simple_test.exs
Normal file
60
test/crypto_simple_test.exs
Normal file
@@ -0,0 +1,60 @@
|
||||
defmodule Odinsea.CryptoSimpleTest do
|
||||
@moduledoc """
|
||||
Simple test module for MapleStory crypto implementation.
|
||||
These tests don't require the full application to start.
|
||||
"""
|
||||
|
||||
use ExUnit.Case
|
||||
|
||||
alias Odinsea.Net.Cipher.{IGCipher, ShandaCipher, AESCipher}
|
||||
|
||||
describe "IGCipher (IV transformation)" do
|
||||
test "inno_hash transforms IV correctly" do
|
||||
iv = <<0x34, 0x9A, 0x0F, 0x0C>>
|
||||
result = IGCipher.inno_hash(iv)
|
||||
|
||||
# Result should be 4 bytes
|
||||
assert byte_size(result) == 4
|
||||
|
||||
# Result should be different from input (usually)
|
||||
assert result != iv
|
||||
end
|
||||
|
||||
test "inno_hash produces deterministic results" do
|
||||
iv = <<0xA8, 0xBC, 0x0D, 0xB3>>
|
||||
result1 = IGCipher.inno_hash(iv)
|
||||
result2 = IGCipher.inno_hash(iv)
|
||||
|
||||
assert result1 == result2
|
||||
end
|
||||
end
|
||||
|
||||
describe "ShandaCipher" do
|
||||
test "encrypt and decrypt are inverse operations" do
|
||||
original = <<1, 0, 7, 112, 0, 4, 0>> # CP_PermissionRequest payload
|
||||
encrypted = ShandaCipher.encrypt(original)
|
||||
decrypted = ShandaCipher.decrypt(encrypted)
|
||||
|
||||
assert decrypted == original
|
||||
end
|
||||
|
||||
test "encrypt produces different output" do
|
||||
original = <<1, 0, 7, 112, 0, 4, 0>>
|
||||
encrypted = ShandaCipher.encrypt(original)
|
||||
|
||||
assert encrypted != original
|
||||
end
|
||||
end
|
||||
|
||||
describe "AESCipher" do
|
||||
test "crypt is self-inverse (XOR property)" do
|
||||
data = <<1, 0, 7, 112, 0, 4, 0>>
|
||||
iv = <<0xA8, 0xBC, 0x0D, 0xB3>>
|
||||
|
||||
encrypted = AESCipher.crypt(data, iv)
|
||||
decrypted = AESCipher.crypt(encrypted, iv)
|
||||
|
||||
assert decrypted == data
|
||||
end
|
||||
end
|
||||
end
|
||||
Reference in New Issue
Block a user