Commit 6ee4ff25 authored by Éloïs's avatar Éloïs Committed by Cédric Moreau

[ref] keyring: add suffix Buggy to functions sign, signSync and verify

parent 3df56aaf
......@@ -50,11 +50,11 @@ export class Key {
}
}
sign(msg:string) {
return Promise.resolve(this.signSync(msg))
signBuggy(msg:string) {
return Promise.resolve(this.signSyncBuggy(msg))
}
signSync(msg:string) {
signSyncBuggy(msg:string) {
const m = decodeUTF8(msg);
const signedMsg = naclBinding.sign(m, this.rawSec());
const sig = new Uint8Array(crypto_sign_BYTES);
......@@ -85,7 +85,7 @@ export function KeyGen(pub:string, sec:string) {
* Verify a signature against data & public key.
* Return true of false as callback argument.
*/
export function verify(rawMsg:string, rawSig:string, rawPub:string) {
export function verifyBuggy(rawMsg:string, rawSig:string, rawPub:string) {
const msg = decodeUTF8(rawMsg);
const sig = decodeBase64(rawSig);
const pub = Base58decode(rawPub);
......
......@@ -13,7 +13,7 @@
import {hashf} from "../common"
import {Cloneable} from "./Cloneable"
import {verify} from "../common-libs/crypto/keyring"
import {verifyBuggy} from "../common-libs/crypto/keyring"
export interface BaseDTO {
base: number
......@@ -245,7 +245,7 @@ export class TransactionDTO implements Cloneable {
while (matching && i < this.signatures.length) {
const sig = this.signatures[i]
const pub = this.issuers[i]
sigResult.sigs[i].ok = matching = verify(raw, sig, pub)
sigResult.sigs[i].ok = matching = verifyBuggy(raw, sig, pub)
i++
}
return sigResult
......
......@@ -18,7 +18,7 @@ import {RevocationDTO} from "./dto/RevocationDTO"
import {CertificationDTO} from "./dto/CertificationDTO"
import {TransactionDTO} from "./dto/TransactionDTO"
import {DBHead} from "./db/DBHead"
import {verify} from "./common-libs/crypto/keyring"
import {verifyBuggy} from "./common-libs/crypto/keyring"
import {rawer, txunlock} from "./common-libs/index"
import {CommonConstants} from "./common-libs/constants"
import {MembershipDTO} from "./dto/MembershipDTO"
......@@ -2089,7 +2089,7 @@ async function sigCheckRevoke(entry: MindexEntry, dal: FileDAL, currency: string
sig: idty.sig,
revocation: ''
});
let sigOK = verify(rawRevocation, sig, pubkey);
let sigOK = verifyBuggy(rawRevocation, sig, pubkey);
if (!sigOK) {
throw Error("Revocation signature must match");
}
......@@ -2144,7 +2144,7 @@ async function checkCertificationIsValid (block: BlockDTO, cert: CindexEntry, fi
buid: buid,
sig: ''
})
const verified = verify(raw, cert.sig, cert.issuer);
const verified = verifyBuggy(raw, cert.sig, cert.issuer);
if (!verified) {
throw constants.ERRORS.WRONG_SIGNATURE_FOR_CERT
}
......
......@@ -16,7 +16,7 @@ import {FileDAL} from "../dal/fileDAL"
import {DBBlock} from "../db/DBBlock"
import {TransactionDTO, TxSignatureResult} from "../dto/TransactionDTO"
import {BlockDTO} from "../dto/BlockDTO"
import {verify} from "../common-libs/crypto/keyring"
import {verifyBuggy} from "../common-libs/crypto/keyring"
import {rawer, txunlock} from "../common-libs/index"
import {CommonConstants} from "../common-libs/constants"
import {IdentityDTO} from "../dto/IdentityDTO"
......@@ -317,7 +317,7 @@ async function checkCertificationShouldBeValid (block:{ number:number, currency:
buid: buid,
sig: ''
})
const verified = verify(raw, cert.sig, cert.from);
const verified = verifyBuggy(raw, cert.sig, cert.from);
if (!verified) {
throw constants.ERRORS.WRONG_SIGNATURE_FOR_CERT
}
......
......@@ -16,7 +16,7 @@ import {ConfDTO} from "../dto/ConfDTO"
import {CindexEntry, IndexEntry, Indexer, MindexEntry, SindexEntry} from "../indexer"
import {BaseDTO, TransactionDTO} from "../dto/TransactionDTO"
import {DBBlock} from "../db/DBBlock"
import {verify} from "../common-libs/crypto/keyring"
import {verifyBuggy} from "../common-libs/crypto/keyring"
import {hashf} from "../common"
import {CommonConstants} from "../common-libs/constants"
import {IdentityDTO} from "../dto/IdentityDTO"
......@@ -87,7 +87,7 @@ export const LOCAL_RULES_FUNCTIONS = {
},
checkBlockSignature: async (block:BlockDTO) => {
if (!verify(block.getSignedPart(), block.signature, block.issuer))
if (!verifyBuggy(block.getSignedPart(), block.signature, block.issuer))
throw Error('Block\'s signature must match');
return true;
},
......@@ -108,7 +108,7 @@ export const LOCAL_RULES_FUNCTIONS = {
while (!wrongSig && i < block.identities.length) {
const idty = IdentityDTO.fromInline(block.identities[i]);
idty.currency = block.currency;
wrongSig = !verify(idty.rawWithoutSig(), idty.sig, idty.pubkey);
wrongSig = !verifyBuggy(idty.rawWithoutSig(), idty.sig, idty.pubkey);
if (wrongSig) {
throw Error('Identity\'s signature must match');
}
......@@ -439,7 +439,7 @@ function getTransactionDepth(txHash:string, sindex:SindexShortEntry[], localDept
}
function checkSingleMembershipSignature(ms:any) {
return verify(ms.getRaw(), ms.signature, ms.issuer);
return verifyBuggy(ms.getRaw(), ms.signature, ms.issuer);
}
function checkBunchOfTransactions(transactions:TransactionDTO[], conf:ConfDTO, medianTime: number, options?:{ dontCareAboutChaining?:boolean }){
......
......@@ -12,7 +12,7 @@
// GNU Affero General Public License for more details.
import {Contacter} from "./contacter"
import {verify} from "../../../lib/common-libs/crypto/keyring"
import {verifyBuggy} from "../../../lib/common-libs/crypto/keyring"
import {rawer} from "../../../lib/common-libs/index"
import {HttpRequirements} from "../../bma/lib/dtos"
......@@ -80,7 +80,7 @@ export const req2fwd = async (requirements: HttpRequirements, toHost:string, toP
buid: received.blockstamp
});
try {
const chkSig = verify(rawCertNoSig, received.sig, received.from)
const chkSig = verifyBuggy(rawCertNoSig, received.sig, received.from)
if (!chkSig) {
throw "Wrong signature for certification?!"
}
......
......@@ -19,7 +19,7 @@ import {GLOBAL_RULES_HELPERS} from "../../../lib/rules/global_rules"
import {LOCAL_RULES_HELPERS} from "../../../lib/rules/local_rules"
import {Indexer} from "../../../lib/indexer"
import {DBBlock} from "../../../lib/db/DBBlock"
import {verify} from "../../../lib/common-libs/crypto/keyring"
import {verifyBuggy} from "../../../lib/common-libs/crypto/keyring"
import {rawer} from "../../../lib/common-libs/index"
import {hashf} from "../../../lib/common"
import {CommonConstants} from "../../../lib/common-libs/constants"
......@@ -380,7 +380,7 @@ export class BlockGenerator {
const idty = IdentityDTO.fromJSONObject(identity);
idty.currency = this.conf.currency;
const createIdentity = idty.rawWithoutSig();
const verified = verify(createIdentity, idty.sig, idty.pubkey);
const verified = verifyBuggy(createIdentity, idty.sig, idty.pubkey);
if (!verified) {
throw constants.ERRORS.IDENTITY_WRONGLY_SIGNED;
}
......@@ -761,7 +761,7 @@ class NextBlockGenerator implements BlockGeneratorInterface {
idty_sig: targetIdty.sig,
buid: current ? [cert.block_number, targetBlock.hash].join('-') : CommonConstants.SPECIAL_BLOCK,
}).getRawUnSigned();
if (verify(rawCert, certSig, cert.from)) {
if (verifyBuggy(rawCert, certSig, cert.from)) {
cert.sig = certSig;
let exists = false;
if (current) {
......
......@@ -121,7 +121,7 @@ export function createPowWorker() {
}
else {
lastSecret = pair.sec;
sigFunc = (msg:string) => KeyGen(pair.pub, pair.sec).signSync(msg)
sigFunc = (msg:string) => KeyGen(pair.pub, pair.sec).signSyncBuggy(msg)
}
signatureFunc = sigFunc;
let pow = "", sig = "", raw = "";
......
......@@ -24,7 +24,7 @@ import {WS2PConstants} from "./constants"
import {PeerDTO, WS2PEndpoint} from '../../../lib/dto/PeerDTO';
import {GlobalFifoPromise} from "../../../service/GlobalFifoPromise"
import {OtherConstants} from "../../../lib/other_constants"
import {Key, verify} from "../../../lib/common-libs/crypto/keyring"
import {Key, verifyBuggy} from "../../../lib/common-libs/crypto/keyring"
import {WS2PServerMessageHandler} from "./interface/WS2PServerMessageHandler"
import {WS2PMessageHandler} from "./impl/WS2PMessageHandler"
import {CommonConstants} from '../../../lib/common-libs/constants';
......@@ -208,8 +208,8 @@ export class WS2PCluster {
) {
const head:WS2PHead = { message: h.message, sig: h.sig, messageV2: h.messageV2, sigV2: h.sigV2, step: h.step }
const sigOK = verify(head.message, head.sig, pub)
const sigV2OK = (head.messageV2 !== undefined && head.sigV2 !== undefined) ? verify(head.messageV2, head.sigV2, pub):false
const sigOK = verifyBuggy(head.message, head.sig, pub)
const sigV2OK = (head.messageV2 !== undefined && head.sigV2 !== undefined) ? verifyBuggy(head.messageV2, head.sigV2, pub):false
if ((sigV2OK && sigOK) || sigOK) {
// Already known or more recent or closer ?
const step = (this.headsCache[fullId]) ? this.headsCache[fullId].step || 0:0
......@@ -605,9 +605,9 @@ export class WS2PCluster {
const prefix = this.server.conf.prefix || ProverConstants.DEFAULT_PEER_ID
const { freeMemberRoom , freeMirorRoom } = await this.countFreeRooms()
const message = `${api}:HEAD:1:${key.publicKey}:${number}-${hash}:${ws2pId}:${software}:${softVersion}:${prefix}`
const sig = key.signSync(message)
const sig = key.signSyncBuggy(message)
const messageV2 = `${api}:HEAD:2:${key.publicKey}:${number}-${hash}:${ws2pId}:${software}:${softVersion}:${prefix}:${freeMemberRoom}:${freeMirorRoom}`
const sigV2 = key.signSync(messageV2)
const sigV2 = key.signSyncBuggy(messageV2)
const myHead:WS2PHead = {
message,
......
......@@ -11,7 +11,7 @@
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU Affero General Public License for more details.
import {Key, verify} from "../../../lib/common-libs/crypto/keyring"
import {Key, verifyBuggy} from "../../../lib/common-libs/crypto/keyring"
import {WS2PMessageHandler} from "./impl/WS2PMessageHandler"
import {BlockDTO} from "../../../lib/dto/BlockDTO"
import {IdentityDTO} from "../../../lib/dto/IdentityDTO"
......@@ -129,7 +129,7 @@ export class WS2PPubkeyRemoteAuth implements WS2PRemoteAuth {
async sendACK(ws: any): Promise<void> {
const challengeMessage = `WS2P:ACK:${this.currency}:${this.pair.pub}:${this.challenge}`
Logger.log('sendACK >>> ' + challengeMessage)
const sig = this.pair.signSync(challengeMessage)
const sig = this.pair.signSyncBuggy(challengeMessage)
await ws.send(JSON.stringify({
auth: 'ACK',
pub: this.pair.pub,
......@@ -153,7 +153,7 @@ export class WS2PPubkeyRemoteAuth implements WS2PRemoteAuth {
this.givenCurrency.resolve(this.currency)
const challengeMessage = (ws2pVersion > 1) ? `WS2P:${type}:${this.currency}:${pub}:${ws2pId}:${challenge}`:`WS2P:${type}:${this.currency}:${pub}:${challenge}`
Logger.log('registerCONNECT >>> ' + challengeMessage)
const verified = verify(challengeMessage, sig, pub)
const verified = verifyBuggy(challengeMessage, sig, pub)
if (verified) {
this.remoteVersion = ws2pVersion
this.challenge = challenge
......@@ -166,7 +166,7 @@ export class WS2PPubkeyRemoteAuth implements WS2PRemoteAuth {
async registerOK(sig: string): Promise<boolean> {
const challengeMessage = `WS2P:OK:${this.currency}:${this.remotePub}:${this.challenge}`
Logger.log('registerOK >>> ' + challengeMessage)
this.authenticatedByRemote = verify(challengeMessage, sig, this.remotePub)
this.authenticatedByRemote = verifyBuggy(challengeMessage, sig, this.remotePub)
if (!this.authenticatedByRemote) {
this.serverAuthReject("Wrong signature from remote OK")
} else {
......@@ -215,7 +215,7 @@ export class WS2PPubkeyLocalAuth implements WS2PLocalAuth {
if (ws2pVersion > 1) {
const challengeMessage = `WS2P:${ws2pVersion}:${connectWord}:${this.currency}:${this.pair.pub}:${this.ws2pId}:${this.challenge}`
Logger.log('sendCONNECT >>> ' + challengeMessage)
const sig = this.pair.signSync(challengeMessage)
const sig = this.pair.signSyncBuggy(challengeMessage)
await ws.send(JSON.stringify({
auth: `${connectWord}`,
version: ws2pVersion,
......@@ -229,7 +229,7 @@ export class WS2PPubkeyLocalAuth implements WS2PLocalAuth {
} else if (ws2pVersion == 1) {
const challengeMessage = `WS2P:${connectWord}:${this.currency}:${this.pair.pub}:${this.challenge}`
Logger.log('sendCONNECT >>> ' + challengeMessage)
const sig = this.pair.signSync(challengeMessage)
const sig = this.pair.signSyncBuggy(challengeMessage)
await ws.send(JSON.stringify({
auth: `${connectWord}`,
pub: this.pair.pub,
......@@ -248,7 +248,7 @@ export class WS2PPubkeyLocalAuth implements WS2PLocalAuth {
}
const challengeMessage = `WS2P:ACK:${this.currency}:${pub}:${this.challenge}`
Logger.log('registerACK >>> ' + challengeMessage)
this.authenticated = verify(challengeMessage, sig, pub)
this.authenticated = verifyBuggy(challengeMessage, sig, pub)
if (!this.authenticated) {
this.serverAuthReject("Wrong signature from server ACK")
} else {
......@@ -260,7 +260,7 @@ export class WS2PPubkeyLocalAuth implements WS2PLocalAuth {
async sendOK(ws:any): Promise<void> {
const challengeMessage = `WS2P:OK:${this.currency}:${this.pair.pub}:${this.challenge}`
Logger.log('sendOK >>> ' + challengeMessage)
const sig = this.pair.signSync(challengeMessage)
const sig = this.pair.signSyncBuggy(challengeMessage)
await ws.send(JSON.stringify({
auth: 'OK',
sig
......
......@@ -21,7 +21,7 @@ import {RevocationDTO} from "../lib/dto/RevocationDTO"
import {BasicIdentity, IdentityDTO} from "../lib/dto/IdentityDTO"
import {CertificationDTO} from "../lib/dto/CertificationDTO"
import {DBCert} from "../lib/dal/sqliteDAL/CertDAL"
import {verify} from "../lib/common-libs/crypto/keyring"
import {verifyBuggy} from "../lib/common-libs/crypto/keyring"
import {FIFOService} from "./FIFOService"
import {MindexEntry} from "../lib/indexer"
import {DataErrors} from "../lib/common-libs/errors"
......@@ -121,7 +121,7 @@ export class IdentityService extends FIFOService {
this.logger.info('⬇ IDTY %s %s', idty.pubkey, idty.uid);
try {
// Check signature's validity
let verified = verify(createIdentity, idty.sig, idty.pubkey);
let verified = verifyBuggy(createIdentity, idty.sig, idty.pubkey);
if (!verified) {
throw constants.ERRORS.SIGNATURE_DOES_NOT_MATCH;
}
......@@ -271,7 +271,7 @@ export class IdentityService extends FIFOService {
return this.pushFIFO<RevocationDTO>(hash, async () => {
try {
this.logger.info('⬇ REVOCATION %s %s', revoc.pubkey, revoc.idty_uid);
let verified = verify(raw, revoc.revocation, revoc.pubkey);
let verified = verifyBuggy(raw, revoc.revocation, revoc.pubkey);
if (!verified) {
throw 'Wrong signature for revocation';
}
......
......@@ -16,7 +16,7 @@ import {FileDAL} from "../lib/dal/fileDAL"
import {DBBlock} from "../lib/db/DBBlock"
import {Multicaster} from "../lib/streams/multicaster"
import {PeerDTO} from "../lib/dto/PeerDTO"
import {verify} from "../lib/common-libs/crypto/keyring"
import {verifyBuggy} from "../lib/common-libs/crypto/keyring"
import {dos2unix} from "../lib/common-libs/dos2unix"
import {rawer} from "../lib/common-libs/index"
import {Server} from "../../server"
......@@ -82,7 +82,7 @@ export class PeeringService {
const raw = rawer.getPeerWithoutSignature(p);
const sig = p.signature;
const pub = p.pubkey;
const signaturesMatching = verify(raw, sig, pub);
const signaturesMatching = verifyBuggy(raw, sig, pub);
return !!signaturesMatching;
};
......
......@@ -14,7 +14,7 @@
"use strict";
import {Base58decode, Base58encode} from "../../../app/lib/common-libs/crypto/base58"
import {decodeBase64, encodeBase64} from "../../../app/lib/common-libs/crypto/nacl-util"
import {KeyGen, verify} from "../../../app/lib/common-libs/crypto/keyring"
import {KeyGen, verifyBuggy} from "../../../app/lib/common-libs/crypto/keyring"
const should = require('should');
......@@ -46,16 +46,16 @@ describe('ed25519 tests:', function(){
it('good signature from generated key should be verified', function(done){
const msg = "Some message to be signed";
const sig = KeyGen(rawPub, rawSec).signSync(msg);
const verified = verify(msg, sig, rawPub);
const sig = KeyGen(rawPub, rawSec).signSyncBuggy(msg);
const verified = verifyBuggy(msg, sig, rawPub);
verified.should.equal(true);
done();
});
it('wrong signature from generated key should NOT be verified', function(done){
const msg = "Some message to be signed";
const sig = KeyGen(rawPub, rawSec).signSync(msg);
const verified = verify(msg + 'delta', sig, rawPub);
const sig = KeyGen(rawPub, rawSec).signSyncBuggy(msg);
const verified = verifyBuggy(msg + 'delta', sig, rawPub);
verified.should.equal(false);
done();
});
......@@ -68,7 +68,7 @@ describe('ed25519 tests:', function(){
"Block: 33291-0000088375C232A4DDAE171BB3D3C51347CB6DC8B7AA8BE4CD4DAEEADF26FEB8\n" +
"Endpoints:\n" +
"BASIC_MERKLED_API g1.duniter.org 10901\n"
const verified = verify(msg, "u8t1IoWrB/C7T+2rS0rKYJfjPG4FN/HkKGFiUO5tILIzjFDvxxQiVC+0o/Vaz805SMmqJvXqornI71U7//+wCg==", "3AF7bhGQRt6ymcBZgZTBMoDsEtSwruSarjNG8kDnaueX");
const verified = verifyBuggy(msg, "u8t1IoWrB/C7T+2rS0rKYJfjPG4FN/HkKGFiUO5tILIzjFDvxxQiVC+0o/Vaz805SMmqJvXqornI71U7//+wCg==", "3AF7bhGQRt6ymcBZgZTBMoDsEtSwruSarjNG8kDnaueX");
verified.should.equal(true);
done();
});
......@@ -82,7 +82,7 @@ describe('ed25519 tests:', function(){
"Endpoints:\n" +
"BASIC_MERKLED_API g1.duniter.tednet.fr 37.187.0.204 8999\n" +
"BMAS g1.duniter.tednet.fr 9000\n"
const verified = verify(msg, "ImvQDdpGv2M6CxSnBuseM/azJhBUGzWVgQhIvb5L2oGLm2GyLk/Sbi5wkb4IjbjbQfdRPdlcx5zxaHhvZCiWAA==", "Com8rJukCozHZyFao6AheSsfDQdPApxQRnz7QYFf64mm");
const verified = verifyBuggy(msg, "ImvQDdpGv2M6CxSnBuseM/azJhBUGzWVgQhIvb5L2oGLm2GyLk/Sbi5wkb4IjbjbQfdRPdlcx5zxaHhvZCiWAA==", "Com8rJukCozHZyFao6AheSsfDQdPApxQRnz7QYFf64mm");
verified.should.equal(true);
done();
});
......
......@@ -11,7 +11,7 @@
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU Affero General Public License for more details.
import {Key, KeyGen, randomKey, verify} from "../../../app/lib/common-libs/crypto/keyring"
import {Key, KeyGen, randomKey, verifyBuggy} from "../../../app/lib/common-libs/crypto/keyring"
const should = require('should');
......@@ -26,16 +26,16 @@ describe('Random keypair', function(){
it('good signature from generated key should be verified', function(done){
const msg = "Some message to be signed";
const sig = KeyGen(key.publicKey, key.secretKey).signSync(msg);
const verified = verify(msg, sig, key.publicKey);
const sig = KeyGen(key.publicKey, key.secretKey).signSyncBuggy(msg);
const verified = verifyBuggy(msg, sig, key.publicKey);
verified.should.equal(true);
done();
});
it('wrong signature from generated key should NOT be verified', function(done){
const msg = "Some message to be signed";
const sig = KeyGen(key.publicKey, key.secretKey).signSync(msg);
const verified = verify(msg + 'delta', sig, key.publicKey);
const sig = KeyGen(key.publicKey, key.secretKey).signSyncBuggy(msg);
const verified = verifyBuggy(msg + 'delta', sig, key.publicKey);
verified.should.equal(false);
done();
});
......
......@@ -11,7 +11,7 @@
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU Affero General Public License for more details.
import {KeyGen, verify} from "../../../../app/lib/common-libs/crypto/keyring"
import {KeyGen, verifyBuggy} from "../../../../app/lib/common-libs/crypto/keyring"
import {Base58decode, Base58encode} from "../../../../app/lib/common-libs/crypto/base58"
const should = require('should');
......@@ -41,16 +41,16 @@ describe('ed25519 tests:', function(){
it('good signature from generated key should be verified', function(done){
const msg = "Some message to be signed";
const sig = KeyGen(rawPub, rawSec).signSync(msg);
const verified = verify(msg, sig, rawPub);
const sig = KeyGen(rawPub, rawSec).signSyncBuggy(msg);
const verified = verifyBuggy(msg, sig, rawPub);
verified.should.equal(true);
done();
});
it('wrong signature from generated key should NOT be verified', function(done){
const msg = "Some message to be signed";
const sig = KeyGen(rawPub, rawSec).signSync(msg);
const verified = verify(msg + 'delta', sig, rawPub);
const sig = KeyGen(rawPub, rawSec).signSyncBuggy(msg);
const verified = verifyBuggy(msg + 'delta', sig, rawPub);
verified.should.equal(false);
done();
});
......
......@@ -11,7 +11,7 @@
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU Affero General Public License for more details.
import {Key, KeyGen, randomKey, verify} from "../../../../app/lib/common-libs/crypto/keyring"
import {Key, KeyGen, randomKey, verifyBuggy} from "../../../../app/lib/common-libs/crypto/keyring"
const should = require('should');
......@@ -26,16 +26,16 @@ describe('Random keypair', function(){
it('good signature from generated key should be verified', function(done){
const msg = "Some message to be signed";
const sig = KeyGen(key.publicKey, key.secretKey).signSync(msg);
const verified = verify(msg, sig, key.publicKey);
const sig = KeyGen(key.publicKey, key.secretKey).signSyncBuggy(msg);
const verified = verifyBuggy(msg, sig, key.publicKey);
verified.should.equal(true);
done();
});
it('wrong signature from generated key should NOT be verified', function(done){
const msg = "Some message to be signed";
const sig = KeyGen(key.publicKey, key.secretKey).signSync(msg);
const verified = verify(msg + 'delta', sig, key.publicKey);
const sig = KeyGen(key.publicKey, key.secretKey).signSyncBuggy(msg);
const verified = verifyBuggy(msg + 'delta', sig, key.publicKey);
verified.should.equal(false);
done();
});
......
......@@ -85,7 +85,7 @@ export class TestUser {
issuer: this.pub,
currency: this.node.server.conf.currency
}).getRawUnSigned()
return this.createdIdentity += KeyGen(this.pub, this.sec).signSync(this.createdIdentity) + '\n'
return this.createdIdentity += KeyGen(this.pub, this.sec).signSyncBuggy(this.createdIdentity) + '\n'
}
public submitIdentity(raw:string, fromServer?: TestingServer) {
......@@ -116,7 +116,7 @@ export class TestUser {
}
Underscore.extend(cert, overrideProps || {});
const rawCert = CertificationDTO.fromJSONObject(cert).getRawUnSigned()
cert.sig = KeyGen(this.pub, this.sec).signSync(rawCert)
cert.sig = KeyGen(this.pub, this.sec).signSyncBuggy(rawCert)
return CertificationDTO.fromJSONObject(cert)
}
......@@ -157,7 +157,7 @@ export class TestUser {
};
Underscore.extend(revocation, overrideProps || {});
const rawRevocation = RevocationDTO.fromJSONObject(revocation).getRawUnsigned()
revocation.revocation = KeyGen(this.pub, this.sec).signSync(rawRevocation);
revocation.revocation = KeyGen(this.pub, this.sec).signSyncBuggy(rawRevocation);
return RevocationDTO.fromJSONObject(revocation)
}
......@@ -185,7 +185,7 @@ export class TestUser {
};
Underscore.extend(join, overrideProps || {});
const rawJoin = MembershipDTO.fromJSONObject(join).getRaw()
join.signature = KeyGen(this.pub, this.sec).signSync(rawJoin)
join.signature = KeyGen(this.pub, this.sec).signSyncBuggy(rawJoin)
return MembershipDTO.fromJSONObject(join)
}
......@@ -306,9 +306,9 @@ export class TestUser {
}
private signed(raw:string, user2?:TestUser) {
let signatures = [KeyGen(this.pub, this.sec).signSync(raw)];
let signatures = [KeyGen(this.pub, this.sec).signSyncBuggy(raw)];
if (user2) {
signatures.push(KeyGen(user2.pub, user2.sec).signSync(raw));
signatures.push(KeyGen(user2.pub, user2.sec).signSyncBuggy(raw));
}
return raw + signatures.join('\n') + '\n';
}
......@@ -356,7 +356,7 @@ export class TestUser {
});
Underscore.extend(peer, overrideProps || {});
const rawPeer = PeerDTO.fromJSONObject(peer).getRawUnsigned()
peer.signature = KeyGen(this.pub, this.sec).signSync(rawPeer)
peer.signature = KeyGen(this.pub, this.sec).signSyncBuggy(rawPeer)
return PeerDTO.fromJSONObject(peer)
}
......
......@@ -18,7 +18,7 @@ import {
WS2PPubkeyRemoteAuth,
WS2PRemoteAuth
} from "../../../app/modules/ws2p/lib/WS2PConnection"
import {Key, verify} from "../../../app/lib/common-libs/crypto/keyring"
import {Key, verifyBuggy} from "../../../app/lib/common-libs/crypto/keyring"
import {getNewTestingPort} from "../tools/toolbox"
import {WS2PMessageHandler} from "../../../app/modules/ws2p/lib/impl/WS2PMessageHandler"
import {WS2PResponse} from "../../../app/modules/ws2p/lib/impl/WS2PResponse"
......@@ -83,7 +83,7 @@ describe('WS2P', () => {
if (obj.auth) {
if (nbAsk == 1 || nbAsk == 3) {
const challengeMessage = `WS2P:ACK:gtest:${serverKeypair.pub}:${obj.challenge}`
const sig = serverKeypair.signSync(challengeMessage)
const sig = serverKeypair.signSyncBuggy(challengeMessage)
if (nbAsk == 1) {
ws.send(JSON.stringify({ auth: 'ACK', pub: serverKeypair.pub, sig: 'hiohoihio' }))
}
......@@ -95,7 +95,7 @@ describe('WS2P', () => {
// We do like if the key was wrong
const clientPub = 'GgTTJLAQ5sqfknMq7yLPZbehtuLSsKj9CxWN7k8QvYJd'
const challengeMessage = `WS2P:CONNECT:${clientPub}:${obj.challenge}`
if (!verify(challengeMessage, obj.sig, clientPub)) {
if (!verifyBuggy(challengeMessage, obj.sig, clientPub)) {
clientAskError = 'Wrong signature from client CONNECT'
}
}
......@@ -332,7 +332,7 @@ describe('WS2P', () => {
class WS2PPubkeyAnsweringWithWrongSigForACK extends WS2PPubkeyRemoteAuth {
async sendACK(ws: any): Promise<void> {
const challengeMessage = `WS2P:WRONG:${this.pair.pub}:${this.challenge}`
const sig = this.pair.signSync(challengeMessage)
const sig = this.pair.signSyncBuggy(challengeMessage)
await ws.send(JSON.stringify({
auth: 'ACK',
pub: this.pair.pub,
......@@ -354,7 +354,7 @@ describe('WS2P', () => {
async registerACK(sig: string, pub: string): Promise<boolean> {
const challengeMessage = `WS2P:BLABLA:${pub}:${this.challenge}`
this.authenticated = verify(challengeMessage, sig, pub)
this.authenticated = verifyBuggy(challengeMessage, sig, pub)
if (!this.authenticated) {
this.serverAuthReject("Wrong signature from server ACK")
} else {
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment