-
Notifications
You must be signed in to change notification settings - Fork 119
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signature for addon manifests (#3751)
* Signature for addon manifests * Set the addon URL for production
- Loading branch information
Showing
32 changed files
with
600 additions
and
105 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
[package] | ||
name = "signature" | ||
version = "0.1.0" | ||
edition = "2021" | ||
|
||
[dependencies] | ||
ring = "0.16.20" | ||
|
||
[lib] | ||
name = "signature" | ||
path = "src/lib.rs" | ||
crate-type = ["staticlib"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
/* This Source Code Form is subject to the terms of the Mozilla Public | ||
* License, v. 2.0. If a copy of the MPL was not distributed with this | ||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */ | ||
|
||
use ring::signature; | ||
use std::os::raw::c_uchar; | ||
|
||
#[no_mangle] | ||
pub extern "C" fn verify_rsa( | ||
public_key_ptr: *const c_uchar, | ||
public_key_length: usize, | ||
message_ptr: *const c_uchar, | ||
message_length: usize, | ||
message_signature_ptr: *const c_uchar, | ||
message_signature_length: usize, | ||
) -> bool { | ||
let public_key_str = unsafe { std::slice::from_raw_parts(public_key_ptr, public_key_length) }; | ||
let public_key = | ||
signature::UnparsedPublicKey::new(&signature::RSA_PKCS1_2048_8192_SHA256, &public_key_str); | ||
|
||
let message_str = unsafe { std::slice::from_raw_parts(message_ptr, message_length) }; | ||
let message_signature_str = | ||
unsafe { std::slice::from_raw_parts(message_signature_ptr, message_signature_length) }; | ||
|
||
match public_key.verify(message_str, message_signature_str) { | ||
Err(e) => { | ||
eprintln!("{}", e); | ||
false | ||
} | ||
Ok(_) => true, | ||
} | ||
} |
Oops, something went wrong.