Skip to content

ed25519 signature malleability #7693

Closed
Closed

Description

@reaperhulk

OpenSSL 1.1.1's current Ed25519 signature verification allows some malleability because it does not implement a check for s being less than the group order as required in RFC 8032 5.1.7. Here is a small code sample that shows this behavior on a signature that should be invalid (a vector from wycheproof):

#include <assert.h>
#include <stdio.h>
#include <string.h>
#include <openssl/crypto.h>
#include <openssl/evp.h>
#include <openssl/x509.h>


int main(void) {
    OPENSSL_init();
    int ret = 0;
    int res;
    unsigned char *public = OPENSSL_hexstr2buf("7d4d0e7f6153a69b6242b522abbee685fda4420f8834b108c3bdae369ef549fa", NULL);
    unsigned char *sig = OPENSSL_hexstr2buf("7c38e026f29e14aabd059a0f2db8b0cd783040609a8be684db12f82a27774ab067654bce3832c2d76f8f6f5dafc08d9339d4eef676573336a5c51eb6f946b31d", NULL);
    unsigned char *msg = OPENSSL_hexstr2buf("54657374", NULL);

    EVP_PKEY *pkey = EVP_PKEY_new_raw_public_key(NID_ED25519, NULL, public, 32);
    assert(pkey != NULL);
    EVP_MD_CTX *ctx = EVP_MD_CTX_new();
    res = EVP_DigestVerifyInit(ctx, NULL, NULL, NULL, pkey);
    assert(res == 1);
    res = EVP_DigestVerify(ctx, sig, 64, msg, 4);
    if (res == 1) {
        printf("Verification passed but should have failed.\n");
        ret = 1;
    }
    exit(ret);
}

Activity

  1. added a commit that references this issue on Nov 23, 2018
    0d624ed
  2. mattcaswell commented on Nov 23, 2018

    @mattcaswell
    Member

    Fix in #7697.

  3. added a commit that references this issue on Dec 3, 2018
    f3243f2
  4. zhangyinpeng commented on Oct 19, 2021

    @zhangyinpeng

    测试

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions