New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix bug in K64F trng_api.c #5550

Merged
merged 1 commit into from Nov 30, 2017

Conversation

Projects
None yet
5 participants
@sarahmarshy
Contributor

sarahmarshy commented Nov 21, 2017

Description

K64F trng_get_byte function assumed memory for byte was zero initialized.

That means that this line would OR random data with data existing in memory. All values will eventually reach 255 if called many times.

Steps to test or reproduce

Use this test program to replicate the issue:

#include "mbed.h"

#define RANDOM_BUFF_SIZE 3                                                           /**< Random numbers buffer size. */

#include "hal/trng_api.h"

int main(void)
{
    uint32_t err_code;

    while (true)
    {
        trng_t trng_obj;
        trng_init(&trng_obj);
        uint8_t p_buff[RANDOM_BUFF_SIZE];
        size_t output_length;
        uint8_t length = trng_get_bytes(&trng_obj, p_buff, RANDOM_BUFF_SIZE, &output_length);
        printf("Random Vector:");
        for(uint8_t i = 0; i < RANDOM_BUFF_SIZE; i++)
        {
            printf(" %u",p_buff[i]);
        }
        printf("\r\n expected: %d length: %d",RANDOM_BUFF_SIZE, output_length);
        printf("\n\r");
        trng_free(&trng_obj);
        wait_ms(3000);
    }
}
@hanno-arm

This comment has been minimized.

Contributor

hanno-arm commented Nov 22, 2017

Thanks for spotting and fixing this!

@0xc0170 Could you also add @mazimkhan as a reviewer, please?

@hanno-arm

LGTM

@theotherjimmy theotherjimmy requested a review from mazimkhan Nov 22, 2017

@mazimkhan

LGTM

@0xc0170 0xc0170 added needs: CI and removed needs: review labels Nov 24, 2017

@0xc0170

This comment has been minimized.

Member

0xc0170 commented Nov 24, 2017

/morph build

@mbed-ci

This comment has been minimized.

mbed-ci commented Nov 24, 2017

Build : SUCCESS

Build number : 590
Build artifacts/logs : http://mbed-os.s3-website-eu-west-1.amazonaws.com/?prefix=builds/5550/

Triggering tests

/morph test
/morph uvisor-test
/morph export-build

@mbed-ci

This comment has been minimized.

@mbed-ci

This comment has been minimized.

@0xc0170

This comment has been minimized.

Member

0xc0170 commented Nov 27, 2017

/morph test

@mbed-ci

This comment has been minimized.

@0xc0170 0xc0170 merged commit a6df4ca into ARMmbed:master Nov 30, 2017

6 checks passed

AWS-CI uVisor Build & Test Success
Details
ci-morph-build build completed
Details
ci-morph-exporter build completed
Details
ci-morph-test test completed
Details
continuous-integration/jenkins/pr-head This commit looks good
Details
continuous-integration/travis-ci/pr The Travis CI build passed
Details
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment