Comments (3)
Another option, which I saw in another library and I think is nice, is to define a new type for each kind of argument. For example, we currently have:
pub fn verify(alg: &VerificationAlgorithm, public_key: Input,
msg: Input, signature: Input) -> Result<(), Unspecified> { ... }
But, we could instead:
enum EncodedPublicKey(untrusted::Input);
enum Signed(untrusted::Input);
enum EncodedSignature(untrusted::Input);
pub fn verify(alg: &VerificationAlgorithm, public_key: EncodedPublicKey,
msg: Signed, signature: EncodedSignature) -> Result<(), Unspecified> { ... }
Pros of such a change:
- It would be much harder for the caller to confuse one input argument for another.
- Future (breaking) changes to the API are likely to result in more compile-time failures and fewer (near zero) runtime failures, which is what we want.
Cons of such a change:
- If somebody isn't doing their parsing using untrusted.rs already, then they would have to wrap their
&[u8]
slices in bothuntrusted::Input
and the wrapper type, which could get really annoying.
from ring.
Input & Reader were moved to ring a long time ago and then factors out into untrusted.rs. We take inputs as untrusted::Input
in several places. We need to comb through the API, especially older APIs, and change the ones that operate on untrusted inputs to take those as untrusted::Input
.
from ring.
Not only did we do this, but everybody hates it. Oh well.
from ring.
Related Issues (20)
- Linker error in v0.17.8
- Build failed on riscv64gc-unknown-linux-gnu arch HOT 1
- Cranelift struggling with SSE & SSE2 check HOT 2
- Directly support Bazel (and GN) for building instead of Cargo/build.rs
- Unsupported architecture compiling for `aarch64-linux-android` using MacOS SDK 14.2
- evaluation of constant value failed -> assert!(cfg!(target_feature = "sse") && cfg!(target_feature = "sse2")) HOT 1
- Error: dangerous relocation: call8: call target out of range:(xtensa-esp32s3-espidf) HOT 1
- assert!(cfg!(target_feature = "sse") && cfg!(target_feature = "sse2")) panic at build on i386, i586, FreeBSD, or many target_os=none x86 targets. HOT 5
- error: failed to run custom build command for `ring v0.16.20` HOT 1
- Consider using `zeroize` crate for key materials
- Build fails on i386: evaluation of constant value failed HOT 1
- failure to verify rsa signature on x509 csr HOT 2
- Fails to build on Linux SPARC HOT 1
- warning: [email protected]: aarch64-fslc-linux-gcc: error: unrecognized command-line option ‘-m64’ HOT 3
- Add riscv64 Support HOT 3
- Disclosure Policy HOT 2
- Attempted to use functionality that requires system randomness!!
- warning: [email protected]: Compiler family detection failed due to error: ToolNotFound: Failed to find tool. Is `C:\Program` installed? HOT 2
- Ring compile error when trying to cross compile from windows 10 to x86_64-unknown-linux-gnu HOT 1
- Ring no longer builds with Rust 1.61 due to cc dependency HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from ring.