Skip to content

Commit

Permalink
Merge pull request #184 from sigstore/dependabot/cargo/base64-0.21.0
Browse files Browse the repository at this point in the history
chore(deps): Update base64 requirement from 0.20.0 to 0.21.0
  • Loading branch information
flavio authored Jan 10, 2023
2 parents 6051265 + 5ba0949 commit 438858d
Show file tree
Hide file tree
Showing 7 changed files with 17 additions and 11 deletions.
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ test-registry = []

[dependencies]
async-trait = "0.1.52"
base64 = "0.20.0"
base64 = "0.21.0"
cached = "0.42.0"
lazy_static = "1.4.0"
oci-distribution = { version = "0.9", default-features = false }
Expand Down
3 changes: 2 additions & 1 deletion src/cosign/constraint/signature.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@

//! Structs that can be used to sign a [`crate::cosign::SignatureLayer`]

use base64::{engine::general_purpose::STANDARD as BASE64_STD_ENGINE, Engine as _};
use tracing::warn;
use zeroize::Zeroizing;

Expand Down Expand Up @@ -66,7 +67,7 @@ impl Constraint for PrivateKeySigner {
}
signature_layer.raw_data = serde_json::to_vec(&signature_layer.simple_signing)?;
let sig = self.key.sign(&signature_layer.raw_data)?;
let sig_base64 = base64::encode(sig);
let sig_base64 = BASE64_STD_ENGINE.encode(sig);
signature_layer.signature = Some(sig_base64);
Ok(true)
}
Expand Down
7 changes: 5 additions & 2 deletions src/crypto/signing_key/kdf.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
//! Please refer to <https://github.com/theupdateframework/go-tuf/blob/master/encrypted/encrypted.go>
//! for golang version.

use base64::{engine::general_purpose::STANDARD as BASE64_STD_ENGINE, Engine as _};
use rand::Rng;
use serde::{Deserialize, Deserializer, Serialize, Serializer};
use xsalsa20poly1305::aead::{AeadMut, KeyInit};
Expand Down Expand Up @@ -73,7 +74,7 @@ fn to_base64<S>(v: &[u8], serializer: S) -> std::result::Result<S::Ok, S::Error>
where
S: Serializer,
{
serializer.serialize_str(&base64::encode(v))
serializer.serialize_str(&BASE64_STD_ENGINE.encode(v))
}

/// Help to deserialize `salt` from base64
Expand All @@ -82,7 +83,9 @@ where
D: Deserializer<'de>,
{
let s = <String>::deserialize(deserializer)?;
base64::decode(s).map_err(serde::de::Error::custom)
BASE64_STD_ENGINE
.decode(s)
.map_err(serde::de::Error::custom)
}

impl Default for ScryptKDF {
Expand Down
3 changes: 2 additions & 1 deletion src/crypto/verification_key.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
// See the License for the specific language governing permissions and
// limitations under the License.

use base64::{engine::general_purpose::STANDARD as BASE64_STD_ENGINE, Engine as _};
use pkcs8::DecodePublicKey;
use rsa::{pkcs1v15, pss};
use sha2::{Digest, Sha256, Sha384};
Expand Down Expand Up @@ -249,7 +250,7 @@ impl CosignVerificationKey {
pub fn verify_signature(&self, signature: Signature, msg: &[u8]) -> Result<()> {
let sig = match signature {
Signature::Raw(data) => data.to_owned(),
Signature::Base64Encoded(data) => base64::decode(data)?,
Signature::Base64Encoded(data) => BASE64_STD_ENGINE.decode(data)?,
};

match self {
Expand Down
5 changes: 3 additions & 2 deletions src/fulcio/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ use crate::crypto::signing_key::SigStoreSigner;
use crate::crypto::SigningScheme;
use crate::errors::{Result, SigstoreError};
use crate::fulcio::oauth::OauthTokenProvider;
use base64::{engine::general_purpose::STANDARD as BASE64_STD_ENGINE, Engine as _};
use openidconnect::core::CoreIdToken;
use reqwest::Body;
use serde::ser::SerializeStruct;
Expand Down Expand Up @@ -135,11 +136,11 @@ impl FulcioClient {

let signer = signing_scheme.create_signer()?;
let signature = signer.sign(challenge.as_bytes())?;
let signature = base64::encode(signature);
let signature = BASE64_STD_ENGINE.encode(signature);

let key_pair = signer.to_sigstore_keypair()?;
let public_key = key_pair.public_key_to_der()?;
let public_key = base64::encode(public_key);
let public_key = BASE64_STD_ENGINE.encode(public_key);

let csr = Csr {
public_key: Some(PublicKey(public_key, signing_scheme)),
Expand Down
4 changes: 2 additions & 2 deletions src/rekor/models/hashedrekord.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
* Generated by: https://openapi-generator.tech
*/

use base64::decode;
use base64::{engine::general_purpose::STANDARD as BASE64_STD_ENGINE, Engine as _};
use serde::{Deserialize, Serialize};

use crate::errors::SigstoreError;
Expand Down Expand Up @@ -81,7 +81,7 @@ impl PublicKey {
}

pub fn decode(&self) -> Result<String, SigstoreError> {
let decoded = decode(&self.content)?;
let decoded = BASE64_STD_ENGINE.decode(&self.content)?;
String::from_utf8(decoded).map_err(|e| SigstoreError::from(e.utf8_error()))
}
}
Expand Down
4 changes: 2 additions & 2 deletions src/rekor/models/log_entry.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use base64::decode;
use base64::{engine::general_purpose::STANDARD as BASE64_STD_ENGINE, Engine as _};
use serde::{Deserialize, Serialize};

use crate::errors::SigstoreError;
Expand All @@ -21,7 +21,7 @@ pub struct LogEntry {

impl LogEntry {
pub fn decode_body(&self) -> Result<Body, SigstoreError> {
let decoded = decode(&self.body)?;
let decoded = BASE64_STD_ENGINE.decode(&self.body)?;
serde_json::from_slice(&decoded).map_err(SigstoreError::from)
}
}
Expand Down

0 comments on commit 438858d

Please sign in to comment.