Zig 0.17.0-dev (Split by item) This is an example of documentation generated by
ZigDoc , an alternative to Zig's built-in
Auto Doc feature. See also
examples in other modes/formats . The project being documented here (as the example) is the Zig standard library.
std › crypto › Certificate › verifyRsa Private Function verifyRsa Doc Source Private Function std.crypto.Certificate.verifyRsa
fn verifyRsa (
comptime Hash : type ,
msg : []const u8 ,
sig : []const u8 ,
pub_key_algo : Parsed .PubKeyAlgo ,
pub_key : []const u8 ,
) !void Params Hash : type msg : []const u8 sig : []const u8 pub_key_algo : Parsed .PubKeyAlgo pub_key : []const u8 File crypto/Certificate.zig: 834
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857 fn verifyRsa (
comptime Hash : type ,
msg : []const u8 ,
sig : []const u8 ,
pub_key_algo : Parsed .PubKeyAlgo ,
pub_key : []const u8 ,
) !void {
if (pub_key_algo != .rsaEncryption ) return error .CertificateSignatureAlgorithmMismatch ;
const pk_components = try rsa .PublicKey .parseDer (pub_key );
const exponent = pk_components .exponent ;
const modulus = pk_components .modulus ;
if (exponent .len > modulus .len ) return error .CertificatePublicKeyInvalid ;
if (sig .len != modulus .len ) return error .CertificateSignatureInvalidLength ;
switch (modulus .len ) {
inline 128 , 256 , 384 , 512 => |modulus_len | {
const public_key = rsa .PublicKey .fromBytes (exponent , modulus ) catch
return error .CertificateSignatureInvalid ;
rsa .PKCS1v1_5Signature .verify (modulus_len , sig [0 ..modulus_len ], msg , public_key , Hash ) catch
return error .CertificateSignatureInvalid ;
},
else => return error .CertificateSignatureUnsupportedBitCount ,
}
}