Pure Rust host-side YubiKey Personal Identity Verification (PIV) driver with general-purpose public-key encryption and signing support.
YubiKeys are versatile devices and through their PIV support, you can use them to store a number of RSA (2048/1024) and ECC (NIST P-256/P-384) private keys with configurable access control policies. Both the signing (RSASSA/ECDSA) and encryption (PKCS#1v1.5/ECIES) use cases are supported for either key type.
If you've been wanting to use Rust to sign and/or encrypt stuff using a private key generated and stored on a Yubikey (with option PIN-based access), this is the crate you've been after!
One small problem, it's not done yet... 😫
But it might be close?
This library is a Rust translation of the yubico-piv-tool utility by Yubico, which was originally written in C. It was mechanically translated from C into Rust using Corrode, and then subsequently heavily refactored into safer, more idiomatic Rust§.
Note that while this project started as a fork of a Yubico project, this fork is NOT an official Yubico project and is in no way supported or endorsed by Yubico.
§ NOTE: This section is actually full of lies and notes aspirations/goals, not history. That said, there's been a decent amount of work cleaning up the mechanically translated code, and at ~5klocs it's not that much.
No security audits of this crate have ever been performed, and it has not been thoroughly assessed to ensure its operation is constant-time on common CPU architectures.
USE AT YOUR OWN RISK!
- Rust 1.39+
We abide by the Contributor Covenant and ask that you do as well.
For more information, please see CODE_OF_CONDUCT.md.
yubikey-piv.rs is a fork of and originally a mechanical translation from
Yubico's yubico-piv-tool
, a C library/CLI program. The original library
was licensed under a 2-Clause BSD License, which this library inherits
as a derived work.
Copyright (c) 2014-2019 Yubico AB, Tony Arcieri All rights reserved.
Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
-
Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
-
Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you shall be licensed under the 2-Clause BSD License as shown above, without any additional terms or conditions.