refactor(crypto): replace byte-slice signing contexts with SigningContext enum
This commit is contained in:
@@ -336,7 +336,7 @@ impl ProposalManager {
|
||||
approve: bool,
|
||||
signature: Vec<u8>,
|
||||
) -> Result<VoteOutcome, Error> {
|
||||
use arbiter_crypto::authn::{self, GOVERNANCE_CONTEXT};
|
||||
use arbiter_crypto::authn::{self, SigningContext};
|
||||
|
||||
let mut conn = self.db.get().await?;
|
||||
|
||||
@@ -391,7 +391,7 @@ impl ProposalManager {
|
||||
let auth_sig = authn::Signature::try_from(signature.as_slice())
|
||||
.map_err(|()| Error::InvalidSignature)?;
|
||||
|
||||
if !pubkey.verify_message(&vote_msg, GOVERNANCE_CONTEXT, &auth_sig) {
|
||||
if !pubkey.verify_message(&vote_msg, SigningContext::GovernanceVote, &auth_sig) {
|
||||
return Err(Error::InvalidSignature);
|
||||
}
|
||||
|
||||
@@ -537,7 +537,7 @@ impl ProposalManager {
|
||||
approve: bool,
|
||||
signature: Vec<u8>,
|
||||
) -> Result<VoteOutcome, Error> {
|
||||
use arbiter_crypto::authn::{self, GOVERNANCE_CONTEXT};
|
||||
use arbiter_crypto::authn::{self, SigningContext};
|
||||
|
||||
let mut conn = self.db.get().await?;
|
||||
|
||||
@@ -596,7 +596,7 @@ impl ProposalManager {
|
||||
let auth_sig = authn::Signature::try_from(signature.as_slice())
|
||||
.map_err(|()| Error::InvalidSignature)?;
|
||||
|
||||
if !pubkey.verify_message(&vote_msg, GOVERNANCE_CONTEXT, &auth_sig) {
|
||||
if !pubkey.verify_message(&vote_msg, SigningContext::GovernanceVote, &auth_sig) {
|
||||
return Err(Error::InvalidSignature);
|
||||
}
|
||||
|
||||
|
||||
@@ -12,7 +12,7 @@ use crate::{
|
||||
schema::program_client,
|
||||
},
|
||||
};
|
||||
use arbiter_crypto::authn::{self, AuthChallenge, CLIENT_CONTEXT};
|
||||
use arbiter_crypto::authn::{self, AuthChallenge, SigningContext};
|
||||
use arbiter_proto::{
|
||||
ClientMetadata,
|
||||
transport::{Bi, expect_message},
|
||||
@@ -306,7 +306,7 @@ where
|
||||
Error::Transport
|
||||
})?;
|
||||
|
||||
if !pubkey.verify(&challenge, CLIENT_CONTEXT, &signature) {
|
||||
if !pubkey.verify(&challenge, SigningContext::Client, &signature) {
|
||||
error!("Challenge solution verification failed");
|
||||
return Err(Error::InvalidChallengeSolution);
|
||||
}
|
||||
|
||||
@@ -7,7 +7,7 @@ use crate::{
|
||||
db::{DatabasePool, schema::operator_identity},
|
||||
peers::operator::auth::Outbound,
|
||||
};
|
||||
use arbiter_crypto::authn::{self, AuthChallenge, OPERATOR_CONTEXT};
|
||||
use arbiter_crypto::authn::{self, AuthChallenge, SigningContext};
|
||||
use arbiter_proto::transport::Bi;
|
||||
|
||||
use diesel::{ExpressionMethods as _, OptionalExtension as _, QueryDsl};
|
||||
@@ -141,7 +141,7 @@ where
|
||||
Error::InvalidChallengeSolution
|
||||
})?;
|
||||
|
||||
let valid = pubkey.verify(challenge, OPERATOR_CONTEXT, &signature);
|
||||
let valid = pubkey.verify(challenge, SigningContext::Operator, &signature);
|
||||
|
||||
if !valid {
|
||||
self.transport
|
||||
|
||||
Reference in New Issue
Block a user