Skip to content

Instantly share code, notes, and snippets.

@bdonlan
Created February 12, 2018 20:02
Show Gist options
  • Save bdonlan/a6b8fce7f6175bd695254b7aef438199 to your computer and use it in GitHub Desktop.
Save bdonlan/a6b8fce7f6175bd695254b7aef438199 to your computer and use it in GitHub Desktop.
Standalone test for OPENSSL_ia32_rdrand_bytes bug
/*
* Copyright 2018 Amazon.com, Inc. or its affiliates. All Rights Reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License").
* You may not use this file except in compliance with the License.
* A copy of the License is located at
*
* http://aws.amazon.com/apache2.0
*
* or in the "license" file accompanying this file. This file is distributed
* on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
* express or implied. See the License for the specific language governing
* permissions and limitations under the License.
*/
#include <stdio.h>
#include <openssl/rsa.h>
size_t OPENSSL_ia32_rdrand_bytes(unsigned char *buf, size_t len);
void dump() {
unsigned char buf[7];
OPENSSL_ia32_rdrand_bytes(buf, sizeof(buf));
for (int i = 0; i < sizeof(buf); i++) {
printf("%02x ", buf[i]);
}
printf("\n");
}
int main() {
for (int i = 0; i < 25; i++) {
dump();
}
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment