-
Notifications
You must be signed in to change notification settings - Fork 16
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
export password hashing funcs and move to wire pkg
- Loading branch information
Showing
2 changed files
with
49 additions
and
33 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
package wire | ||
|
||
import ( | ||
"crypto/md5" | ||
"io" | ||
) | ||
|
||
// WeakMD5PasswordHash hashes password and authKey for AIM v3.5-v4.7. | ||
// | ||
//goland:noinspection ALL | ||
func WeakMD5PasswordHash(pass, authKey string) []byte { | ||
hash := md5.New() | ||
io.WriteString(hash, authKey) | ||
io.WriteString(hash, pass) | ||
io.WriteString(hash, "AOL Instant Messenger (SM)") | ||
return hash.Sum(nil) | ||
} | ||
|
||
// StrongMD5PasswordHash hashes password and authKey for AIM v4.8+. | ||
// | ||
//goland:noinspection ALL | ||
func StrongMD5PasswordHash(pass, authKey string) []byte { | ||
top := md5.New() | ||
io.WriteString(top, pass) | ||
bottom := md5.New() | ||
io.WriteString(bottom, authKey) | ||
bottom.Write(top.Sum(nil)) | ||
io.WriteString(bottom, "AOL Instant Messenger (SM)") | ||
return bottom.Sum(nil) | ||
} | ||
|
||
// RoastPassword toggles password obfuscation using a roasting algorithm for | ||
// AIM v1.0-v3.0 auth. The first call obfuscates the password, and the second | ||
// call de-obfuscates the password, and so on. | ||
func RoastPassword(roastedPass []byte) []byte { | ||
var roastTable = [16]byte{ | ||
0xF3, 0x26, 0x81, 0xC4, 0x39, 0x86, 0xDB, 0x92, | ||
0x71, 0xA3, 0xB9, 0xE6, 0x53, 0x7A, 0x95, 0x7C, | ||
} | ||
clearPass := make([]byte, len(roastedPass)) | ||
for i := range roastedPass { | ||
clearPass[i] = roastedPass[i] ^ roastTable[i%len(roastTable)] | ||
} | ||
return clearPass | ||
} |