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

Support hs2019 signatures #92

Open
fauno opened this issue Nov 13, 2024 · 2 comments
Open

Support hs2019 signatures #92

fauno opened this issue Nov 13, 2024 · 2 comments
Labels
enhancement New feature or request

Comments

@fauno
Copy link
Collaborator

fauno commented Nov 13, 2024

Following a site from a gotosocial instance throws UnkownAlgorithmError: Don't know how to verify hs2019 signatures.

#24

@fauno fauno added the enhancement New feature or request label Nov 13, 2024
@fauno fauno moved this from Needs triage to Backlog in Distributed Press Organizing Nov 13, 2024
@fauno
Copy link
Collaborator Author

fauno commented Nov 13, 2024

GoToSocial sets the "algorithm" field in signatures to the value hs2019, which essentially means "derive the algorithm from metadata associated with the keyId". The actual algorithm used for generating signatures is RSA_SHA256, which is in line with other ActivityPub implementations. When validating a GoToSocial HTTP signature, remote servers can safely assume that the signature is generated using sha256.

https://docs.gotosocial.org/en/latest/federation/http_signatures/#outgoing-requests

@fauno
Copy link
Collaborator Author

fauno commented Nov 13, 2024

From node_modules/activitypub-http-signatures/src/index.js the issue is that it should assume hs2019 equals rsa-sha256 (!)

export class Parser {

// [...]

	/**
	 * Construct the signature class for a given algorithm.
	 * Override this method if you want to support additional
	 * algorithms.
	 * @param	{string}	algorithm The algorithm used by the signed request
	 * @param	{object}	options
	 * @param	{Buffer}	options.signature	The signature as a buffer
	 * @param	{string}	options.string	The string that was signed
	 * @param	{string}	options.keyId	The ID of the public key to be used for verification
	 * @returns	{Signature}
	 * @throws	{UnkownAlgorithmError}	If an unknown algorithm was used
	 */
	getSignatureClass(algorithm, { signature, string, keyId }) {
		if(algorithm === 'rsa-sha256') {
			return new Sha256Signature({ signature, string, keyId });
		} else {
			throw new UnkownAlgorithmError(`Don't know how to verify ${algorithm} signatures.`);
		}
	}
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
Status: Backlog
Development

No branches or pull requests

1 participant