X-Git-Url: https://git.immae.eu/?a=blobdiff_plain;f=server%2Fhelpers%2Fpeertube-crypto.ts;h=313c12e26fe07f78b1bca2db159602037fdcb05d;hb=a797728009eb5c26cf55624a4a01e8ecb73f1297;hp=c4c735cb84f6517b6ed4e3cb525c06bf25d01807;hpb=3fd3ab2d34d512b160a5e6084d7609be7b4f4452;p=github%2FChocobozzz%2FPeerTube.git diff --git a/server/helpers/peertube-crypto.ts b/server/helpers/peertube-crypto.ts index c4c735cb8..313c12e26 100644 --- a/server/helpers/peertube-crypto.ts +++ b/server/helpers/peertube-crypto.ts @@ -1,5 +1,5 @@ import { BCRYPT_SALT_SIZE, PRIVATE_RSA_KEY_SIZE } from '../initializers' -import { AccountModel } from '../models/account/account' +import { ActorModel } from '../models/activitypub/actor' import { bcryptComparePromise, bcryptGenSaltPromise, bcryptHashPromise, createPrivateKey, getPublicKey } from './core-utils' import { jsig } from './custom-jsonld-signature' import { logger } from './logger' @@ -13,18 +13,18 @@ async function createPrivateAndPublicKeys () { return { privateKey: key, publicKey } } -function isSignatureVerified (fromAccount: AccountModel, signedDocument: object) { +function isSignatureVerified (fromActor: ActorModel, signedDocument: object) { const publicKeyObject = { '@context': jsig.SECURITY_CONTEXT_URL, - '@id': fromAccount.url, + '@id': fromActor.url, '@type': 'CryptographicKey', - owner: fromAccount.url, - publicKeyPem: fromAccount.publicKey + owner: fromActor.url, + publicKeyPem: fromActor.publicKey } const publicKeyOwnerObject = { '@context': jsig.SECURITY_CONTEXT_URL, - '@id': fromAccount.url, + '@id': fromActor.url, publicKey: [ publicKeyObject ] } @@ -40,10 +40,11 @@ function isSignatureVerified (fromAccount: AccountModel, signedDocument: object) }) } -function signObject (byAccount: AccountModel, data: any) { +function signObject (byActor: ActorModel, data: any) { const options = { - privateKeyPem: byAccount.privateKey, - creator: byAccount.url + privateKeyPem: byActor.privateKey, + creator: byActor.url, + algorithm: 'RsaSignature2017' } return jsig.promises.sign(data, options)