[DiscordArchive] Hello, where is the createVerifier for SRP6 Auth in AzerothCore please ?
[DiscordArchive] Hello, where is the createVerifier for SRP6 Auth in AzerothCore please ?
Archived author: Aspect • Posted: 2022-12-09T09:28:16.824000+00:00
Original source
Hello, where is the createVerifier for SRP6 Auth in AzerothCore please ?
Archived author: Aspect • Posted: 2022-12-09T09:28:29.064000+00:00
Original source
i try to pass js to ts and it doesn't work
Archived author: Aspect • Posted: 2022-12-09T09:58:29.599000+00:00
Original source
```ts
import sha1 from 'sha1'
import { BigInteger } from 'jsbn'
export async function createVerifier(username: string, password: string, salt: Uint8Array) {
const N = new BigInteger("894B645E89E1535BBDAD5B8B290650530801B18EBFBF5E8FAB3C82872A3E9BB7", 16)
const g = new BigInteger("7", 16)
const h1 = Buffer.from(sha1(username.toUpperCase() + ':' + password), 'hex')
const h2 = Buffer.from(sha1(Buffer.concat([salt, h1]))).reverse()
const h2bigint = new BigInteger(h2.toString("hex"), 16)
const verifierBigint = g.modPow(h2bigint, N)
let verifier = Buffer.from(verifierBigint.toByteArray()).reverse()
verifier = verifier.slice(0, 32)
if (verifier.length != 32) {
verifier = Buffer.concat([verifier], 32)
}
return verifier
}```
Archived author: Aspect • Posted: 2022-12-09T09:58:34.951000+00:00
Original source
its my function
Archived author: Roboto • Posted: 2022-12-09T10:18:02.759000+00:00
Original source
I have this snippet from an old project, looks very similar to yours but uses a different package for sha1. Might be the solution, or not, idk
```ts
import sha1 from "js-sha1";
import crypto from "crypto";
import { BigInteger } from "jsbn";
export function createVerifier(username: string, password: string, salt: Buffer = null): Buffer {
// https://gist.github.com/Treeston/db44f23...cb8d66781e
const N = new BigInteger("894B645E89E1535BBDAD5B8B290650530801B18EBFBF5E8FAB3C82872A3E9BB7", 16);
const g = new BigInteger("7", 16);
salt = salt || generateSalt();
// Calculate first hash
const h1: Buffer = Buffer.from(sha1.arrayBuffer(`${username}:${password}`.toUpperCase()));
// Calculate second hash
const h2: Buffer = Buffer.from(sha1.arrayBuffer(Buffer.concat([salt, h1]))).reverse();
// Convert to integer
const h2bigint = new BigInteger(h2.toString("hex"), 16);
// g^h2 mod N
const verifierBigint = g.modPow(h2bigint, N);
// Convert back to a buffer
let verifier = Buffer.from(verifierBigint.toByteArray()).reverse();
// Pad to 32 bytes
verifier = verifier.slice(0, 32);
if (verifier.length != 32) {
verifier = Buffer.concat([verifier], 32);
}
return verifier;
};
export function generateSalt(): Buffer {
return crypto.randomBytes(32);
}
```
Archived author: Aspect • Posted: 2022-12-09T10:34:56.608000+00:00
Original source
Precisely I was using yours before, but I switched to typescript so I tried to make an equivalent, precisely I located that sha1.ArrayBuffer is missing somewhere in relation to Javascript. Only the sha1 package does not offer this to tell the truth... I don't know how to do it
![[Image: image.png?ex=690bd198&is=690a8018&hm=52f...3c61dde97&]](https://cdn.discordapp.com/attachments/284323424032129024/1050722779663704164/image.png?ex=690bd198&is=690a8018&hm=52fa21d950f0ad8e1e86cc6cc52aa161725cc753d5da480f1198ae73c61dde97&)
Archived author: Aspect • Posted: 2022-12-09T10:37:12.273000+00:00
Original source
![[Image: image.png?ex=690bd198&is=690a8018&hm=52f...3c61dde97&]](https://cdn.discordapp.com/attachments/284323424032129024/1050722779663704164/image.png?ex=690bd198&is=690a8018&hm=52fa21d950f0ad8e1e86cc6cc52aa161725cc753d5da480f1198ae73c61dde97&)
Archived author: Aspect • Posted: 2022-12-09T10:37:15.650000+00:00
Original source
and me :
![[Image: image.png?ex=690bd1ab&is=690a802b&hm=73e...ad2d58ee5&]](https://cdn.discordapp.com/attachments/284323424032129024/1050722860596998164/image.png?ex=690bd1ab&is=690a802b&hm=73ea9529bd47239aae76d5a0ecea0739b63621b22569cfd491feee5ad2d58ee5&)
Archived author: Aspect • Posted: 2022-12-09T10:37:31.447000+00:00
Original source
![[Image: image.png?ex=690bd1ab&is=690a802b&hm=73e...ad2d58ee5&]](https://cdn.discordapp.com/attachments/284323424032129024/1050722860596998164/image.png?ex=690bd1ab&is=690a802b&hm=73ea9529bd47239aae76d5a0ecea0739b63621b22569cfd491feee5ad2d58ee5&)
Archived author: Roboto • Posted: 2022-12-09T10:46:52.472000+00:00
Original source
ah maybe the package changed since then