• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

mendersoftware / mender-mcu / 1652801795

03 Feb 2025 08:48AM UTC coverage: 25.939% (+0.3%) from 25.682%
1652801795

push

gitlab-ci

danielskinstad
chore: explicit error for no files in zephyr-image-update-module

Check if the aritfact has a payload file by adding a boolean that's set
when the download artifact flash callback is called.

Ticket: MEN-7804

Signed-off-by: Daniel Skinstad Drabitzius <daniel.drabitzius@northern.tech>

739 of 2849 relevant lines covered (25.94%)

8.56 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

70.97
/platform/sha/generic/mbedtls/src/mender-sha.c
1
/**
2
 * @file      mender-sha.c
3
 * @brief     Mender SHA interface for MbedTLS platform
4
 *
5
 * Copyright Northern.tech AS
6
 *
7
 * Licensed under the Apache License, Version 2.0 (the "License");
8
 * you may not use this file except in compliance with the License.
9
 * You may obtain a copy of the License at
10
 *
11
 *     http://www.apache.org/licenses/LICENSE-2.0
12
 *
13
 * Unless required by applicable law or agreed to in writing, software
14
 * distributed under the License is distributed on an "AS IS" BASIS,
15
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16
 * See the License for the specific language governing permissions and
17
 * limitations under the License.
18
 */
19

20
#include "mender-alloc.h"
21
#include "mender-sha.h"
22
#include "mender-log.h"
23

24
#include <mbedtls/sha256.h>
25

26
mender_err_t
27
mender_sha256_begin(mender_sha256_context_t *context) {
23✔
28
    assert(NULL != context);
23✔
29

30
    mbedtls_sha256_context *ctx = mender_malloc(sizeof(mbedtls_sha256_context));
23✔
31
    if (NULL == ctx) {
23✔
32
        mender_log_error("Unable to allocate memory");
×
33
        return MENDER_FAIL;
×
34
    }
35

36
    mbedtls_sha256_init(ctx);
23✔
37
    if (0 != mbedtls_sha256_starts(ctx, 0 /* Use SHA-256, not SHA-224 */)) {
23✔
38
        mender_log_error("Failed to start SHA-256 checksum calculation");
×
39
        mender_free(ctx);
×
40
        return MENDER_FAIL;
×
41
    }
42

43
    *context = ctx;
23✔
44
    return MENDER_OK;
23✔
45
}
46

47
mender_err_t
48
mender_sha256_update(mender_sha256_context_t context, const unsigned char *input, size_t length) {
47✔
49
    assert(NULL != context);
47✔
50

51
    mbedtls_sha256_context *ctx = context;
47✔
52
    if (0 != mbedtls_sha256_update(ctx, input, length)) {
47✔
53
        mender_log_error("Failed to update SHA-256 checksum calculation");
×
54
        return MENDER_FAIL;
×
55
    }
56

57
    return MENDER_OK;
47✔
58
}
59

60
mender_err_t
61
mender_sha256_finish(mender_sha256_context_t context, unsigned char *output) {
27✔
62
    mender_err_t            ret = MENDER_OK;
27✔
63
    mbedtls_sha256_context *ctx = context;
27✔
64
    if (NULL != ctx) {
27✔
65
        if (NULL != output) {
23✔
66
            if (0 != mbedtls_sha256_finish(ctx, output)) {
4✔
67
                mender_log_error("Failed to finish SHA-256 checksum calculation");
×
68
                ret = MENDER_FAIL;
×
69
            }
70
        }
71
        mbedtls_sha256_free(ctx);
23✔
72
        mender_free(ctx);
23✔
73
    }
74
    return ret;
27✔
75
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2025 Coveralls, Inc