<commit_before>use XML;
use XML::Canonical;
use OpenSSL;
use OpenSSL::RSATools;
use Digest::SHA;
use MIME::Base64;

module XML::Signature;

our sub sign(XML::Element $signature, OpenSSL::RSAKey $private, Str $cert-pem) is export {
    die "Signing NYI";
}

our sub verify(XML::Element $signature) is export {
    my @name = $signature.name.split(/\:/);
    my $prefix = @name[0] ~ ':';
    $prefix = '' unless @name[1];

    die "Must pass a signature element!" unless (@name[1] || @name[0]) eq 'Signature';

    my $signed-info = $signature.elements(:TAG($prefix ~ 'SignedInfo'), :SINGLE);
    my @references = $signed-info.elements(:TAG($prefix ~ 'Reference'));

    for @references {
        fail "Reference failure" unless check_reference($_);<commit_msg>Speculate on API for signing<commit_after>use XML;
use XML::Canonical;
use OpenSSL;
use OpenSSL::RSATools;
use Digest::SHA;
use MIME::Base64;

module XML::Signature;

our sub sign(XML::Element $document, :$private-pem, :$x509-pem, :$enveloping, :$enveloped, :$detached) is export {
    die "Signing NYI";
}

our sub verify(XML::Element $signature) is export {
    my @name = $signature.name.split(/\:/);
    my $prefix = @name[0] ~ ':';
    $prefix = '' unless @name[1];

    die "Must pass a signature element!" unless (@name[1] || @name[0]) eq 'Signature';

    my $signed-info = $signature.elements(:TAG($prefix ~ 'SignedInfo'), :SINGLE);
    my @references = $signed-info.elements(:TAG($prefix ~ 'Reference'));

    for @references {
        fail "Reference failure" unless check_reference($_);
{'fraction_non_alphanumeric': 0.17212588310854207, 'fraction_numerical': 0.009633911368015413, 'mean_word_length': 4.466666666666667, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1510522', 'n_tokens_mistral': 526, 'n_tokens_neox': 512, 'n_words': 142}