Welcome to mirror list, hosted at ThFree Co, Russian Federation.

uxutils.c « unix - github.com/mRemoteNG/PuTTYNG.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 3a04c1becaee5f50de8bae23063f7253d24422d2 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
#include "putty.h"
#include "ssh.h"

#include "uxutils.h"

#if defined __arm__ || defined __aarch64__

bool platform_aes_hw_available(void)
{
#if defined HWCAP_AES
    return getauxval(AT_HWCAP) & HWCAP_AES;
#elif defined HWCAP2_AES
    return getauxval(AT_HWCAP2) & HWCAP2_AES;
#elif defined __APPLE__
    /* M1 macOS defines no optional sysctl flag indicating presence of
     * the AES extension, which I assume to be because it's always
     * present */
    return true;
#else
    return false;
#endif
}

bool platform_sha256_hw_available(void)
{
#if defined HWCAP_SHA2
    return getauxval(AT_HWCAP) & HWCAP_SHA2;
#elif defined HWCAP2_SHA2
    return getauxval(AT_HWCAP2) & HWCAP2_SHA2;
#elif defined __APPLE__
    /* Assume always present on M1 macOS, similarly to AES */
    return true;
#else
    return false;
#endif
}

bool platform_sha1_hw_available(void)
{
#if defined HWCAP_SHA1
    return getauxval(AT_HWCAP) & HWCAP_SHA1;
#elif defined HWCAP2_SHA1
    return getauxval(AT_HWCAP2) & HWCAP2_SHA1;
#elif defined __APPLE__
    /* Assume always present on M1 macOS, similarly to AES */
    return true;
#else
    return false;
#endif
}

bool platform_sha512_hw_available(void)
{
#if defined HWCAP_SHA512
    return getauxval(AT_HWCAP) & HWCAP_SHA512;
#elif defined HWCAP2_SHA512
    return getauxval(AT_HWCAP2) & HWCAP2_SHA512;
#elif defined __APPLE__
    return test_sysctl_flag("hw.optional.armv8_2_sha512");
#else
    return false;
#endif
}

#endif /* defined __arm__ || defined __aarch64__ */