@@ -1666,6 +1666,111 @@ int mg_uecc_verify(const uint8_t *public_key, const uint8_t *message_hash,
16661666
16671667/* Copyright 2015, Kenneth MacKay. Licensed under the BSD 2-clause license. */
16681668
1669+ #ifndef _UECC_TYPES_H_
1670+ #define _UECC_TYPES_H_
1671+
1672+ #ifndef MG_UECC_PLATFORM
1673+ #if defined(__AVR__) && __AVR__
1674+ #define MG_UECC_PLATFORM mg_uecc_avr
1675+ #elif defined(__thumb2__) || \
1676+ defined (_M_ARMT) /* I think MSVC only supports Thumb-2 targets */
1677+ #define MG_UECC_PLATFORM mg_uecc_arm_thumb2
1678+ #elif defined(__thumb__)
1679+ #define MG_UECC_PLATFORM mg_uecc_arm_thumb
1680+ #elif defined(__arm__) || defined(_M_ARM)
1681+ #define MG_UECC_PLATFORM mg_uecc_arm
1682+ #elif defined(__aarch64__)
1683+ #define MG_UECC_PLATFORM mg_uecc_arm64
1684+ #elif defined(__i386__) || defined(_M_IX86) || defined(_X86_) || \
1685+ defined (__I86__)
1686+ #define MG_UECC_PLATFORM mg_uecc_x86
1687+ #elif defined(__amd64__) || defined(_M_X64)
1688+ #define MG_UECC_PLATFORM mg_uecc_x86_64
1689+ #else
1690+ #define MG_UECC_PLATFORM mg_uecc_arch_other
1691+ #endif
1692+ #endif
1693+
1694+ #ifndef MG_UECC_ARM_USE_UMAAL
1695+ #if (MG_UECC_PLATFORM == mg_uecc_arm) && (__ARM_ARCH >= 6)
1696+ #define MG_UECC_ARM_USE_UMAAL 1
1697+ #elif (MG_UECC_PLATFORM == mg_uecc_arm_thumb2) && (__ARM_ARCH >= 6) && \
1698+ (!defined (__ARM_ARCH_7M__) || !__ARM_ARCH_7M__)
1699+ #define MG_UECC_ARM_USE_UMAAL 1
1700+ #else
1701+ #define MG_UECC_ARM_USE_UMAAL 0
1702+ #endif
1703+ #endif
1704+
1705+ #ifndef MG_UECC_WORD_SIZE
1706+ #if MG_UECC_PLATFORM == mg_uecc_avr
1707+ #define MG_UECC_WORD_SIZE 1
1708+ #elif (MG_UECC_PLATFORM == mg_uecc_x86_64 || MG_UECC_PLATFORM == mg_uecc_arm64)
1709+ #define MG_UECC_WORD_SIZE 8
1710+ #else
1711+ #define MG_UECC_WORD_SIZE 4
1712+ #endif
1713+ #endif
1714+
1715+ #if (MG_UECC_WORD_SIZE != 1) && (MG_UECC_WORD_SIZE != 4) && \
1716+ (MG_UECC_WORD_SIZE != 8 )
1717+ #error "Unsupported value for MG_UECC_WORD_SIZE"
1718+ #endif
1719+
1720+ #if ((MG_UECC_PLATFORM == mg_uecc_avr) && (MG_UECC_WORD_SIZE != 1))
1721+ #pragma message("MG_UECC_WORD_SIZE must be 1 for AVR")
1722+ #undef MG_UECC_WORD_SIZE
1723+ #define MG_UECC_WORD_SIZE 1
1724+ #endif
1725+
1726+ #if ((MG_UECC_PLATFORM == mg_uecc_arm || \
1727+ MG_UECC_PLATFORM == mg_uecc_arm_thumb || \
1728+ MG_UECC_PLATFORM == mg_uecc_arm_thumb2) && \
1729+ (MG_UECC_WORD_SIZE != 4 ))
1730+ #pragma message("MG_UECC_WORD_SIZE must be 4 for ARM")
1731+ #undef MG_UECC_WORD_SIZE
1732+ #define MG_UECC_WORD_SIZE 4
1733+ #endif
1734+
1735+ typedef int8_t wordcount_t ;
1736+ typedef int16_t bitcount_t ;
1737+ typedef int8_t cmpresult_t ;
1738+
1739+ #if (MG_UECC_WORD_SIZE == 1)
1740+
1741+ typedef uint8_t mg_uecc_word_t ;
1742+ typedef uint16_t mg_uecc_dword_t ;
1743+
1744+ #define HIGH_BIT_SET 0x80
1745+ #define MG_UECC_WORD_BITS 8
1746+ #define MG_UECC_WORD_BITS_SHIFT 3
1747+ #define MG_UECC_WORD_BITS_MASK 0x07
1748+
1749+ #elif (MG_UECC_WORD_SIZE == 4)
1750+
1751+ typedef uint32_t mg_uecc_word_t ;
1752+ typedef uint64_t mg_uecc_dword_t ;
1753+
1754+ #define HIGH_BIT_SET 0x80000000
1755+ #define MG_UECC_WORD_BITS 32
1756+ #define MG_UECC_WORD_BITS_SHIFT 5
1757+ #define MG_UECC_WORD_BITS_MASK 0x01F
1758+
1759+ #elif (MG_UECC_WORD_SIZE == 8)
1760+
1761+ typedef uint64_t mg_uecc_word_t ;
1762+
1763+ #define HIGH_BIT_SET 0x8000000000000000U
1764+ #define MG_UECC_WORD_BITS 64
1765+ #define MG_UECC_WORD_BITS_SHIFT 6
1766+ #define MG_UECC_WORD_BITS_MASK 0x03F
1767+
1768+ #endif /* MG_UECC_WORD_SIZE */
1769+
1770+ #endif /* _UECC_TYPES_H_ */
1771+
1772+ /* Copyright 2015, Kenneth MacKay. Licensed under the BSD 2-clause license. */
1773+
16691774#ifndef _UECC_VLI_H_
16701775#define _UECC_VLI_H_
16711776
@@ -1832,110 +1937,6 @@ int mg_uecc_generate_random_int(mg_uecc_word_t *random,
18321937
18331938#endif /* _UECC_VLI_H_ */
18341939
1835- /* Copyright 2015, Kenneth MacKay. Licensed under the BSD 2-clause license. */
1836-
1837- #ifndef _UECC_TYPES_H_
1838- #define _UECC_TYPES_H_
1839-
1840- #ifndef MG_UECC_PLATFORM
1841- #if defined(__AVR__) && __AVR__
1842- #define MG_UECC_PLATFORM mg_uecc_avr
1843- #elif defined(__thumb2__) || \
1844- defined (_M_ARMT) /* I think MSVC only supports Thumb-2 targets */
1845- #define MG_UECC_PLATFORM mg_uecc_arm_thumb2
1846- #elif defined(__thumb__)
1847- #define MG_UECC_PLATFORM mg_uecc_arm_thumb
1848- #elif defined(__arm__) || defined(_M_ARM)
1849- #define MG_UECC_PLATFORM mg_uecc_arm
1850- #elif defined(__aarch64__)
1851- #define MG_UECC_PLATFORM mg_uecc_arm64
1852- #elif defined(__i386__) || defined(_M_IX86) || defined(_X86_) || \
1853- defined (__I86__)
1854- #define MG_UECC_PLATFORM mg_uecc_x86
1855- #elif defined(__amd64__) || defined(_M_X64)
1856- #define MG_UECC_PLATFORM mg_uecc_x86_64
1857- #else
1858- #define MG_UECC_PLATFORM mg_uecc_arch_other
1859- #endif
1860- #endif
1861-
1862- #ifndef MG_UECC_ARM_USE_UMAAL
1863- #if (MG_UECC_PLATFORM == mg_uecc_arm) && (__ARM_ARCH >= 6)
1864- #define MG_UECC_ARM_USE_UMAAL 1
1865- #elif (MG_UECC_PLATFORM == mg_uecc_arm_thumb2) && (__ARM_ARCH >= 6) && \
1866- (!defined (__ARM_ARCH_7M__) || !__ARM_ARCH_7M__)
1867- #define MG_UECC_ARM_USE_UMAAL 1
1868- #else
1869- #define MG_UECC_ARM_USE_UMAAL 0
1870- #endif
1871- #endif
1872-
1873- #ifndef MG_UECC_WORD_SIZE
1874- #if MG_UECC_PLATFORM == mg_uecc_avr
1875- #define MG_UECC_WORD_SIZE 1
1876- #elif (MG_UECC_PLATFORM == mg_uecc_x86_64 || MG_UECC_PLATFORM == mg_uecc_arm64)
1877- #define MG_UECC_WORD_SIZE 8
1878- #else
1879- #define MG_UECC_WORD_SIZE 4
1880- #endif
1881- #endif
1882-
1883- #if (MG_UECC_WORD_SIZE != 1) && (MG_UECC_WORD_SIZE != 4) && \
1884- (MG_UECC_WORD_SIZE != 8 )
1885- #error "Unsupported value for MG_UECC_WORD_SIZE"
1886- #endif
1887-
1888- #if ((MG_UECC_PLATFORM == mg_uecc_avr) && (MG_UECC_WORD_SIZE != 1))
1889- #pragma message("MG_UECC_WORD_SIZE must be 1 for AVR")
1890- #undef MG_UECC_WORD_SIZE
1891- #define MG_UECC_WORD_SIZE 1
1892- #endif
1893-
1894- #if ((MG_UECC_PLATFORM == mg_uecc_arm || \
1895- MG_UECC_PLATFORM == mg_uecc_arm_thumb || \
1896- MG_UECC_PLATFORM == mg_uecc_arm_thumb2) && \
1897- (MG_UECC_WORD_SIZE != 4 ))
1898- #pragma message("MG_UECC_WORD_SIZE must be 4 for ARM")
1899- #undef MG_UECC_WORD_SIZE
1900- #define MG_UECC_WORD_SIZE 4
1901- #endif
1902-
1903- typedef int8_t wordcount_t ;
1904- typedef int16_t bitcount_t ;
1905- typedef int8_t cmpresult_t ;
1906-
1907- #if (MG_UECC_WORD_SIZE == 1)
1908-
1909- typedef uint8_t mg_uecc_word_t ;
1910- typedef uint16_t mg_uecc_dword_t ;
1911-
1912- #define HIGH_BIT_SET 0x80
1913- #define MG_UECC_WORD_BITS 8
1914- #define MG_UECC_WORD_BITS_SHIFT 3
1915- #define MG_UECC_WORD_BITS_MASK 0x07
1916-
1917- #elif (MG_UECC_WORD_SIZE == 4)
1918-
1919- typedef uint32_t mg_uecc_word_t ;
1920- typedef uint64_t mg_uecc_dword_t ;
1921-
1922- #define HIGH_BIT_SET 0x80000000
1923- #define MG_UECC_WORD_BITS 32
1924- #define MG_UECC_WORD_BITS_SHIFT 5
1925- #define MG_UECC_WORD_BITS_MASK 0x01F
1926-
1927- #elif (MG_UECC_WORD_SIZE == 8)
1928-
1929- typedef uint64_t mg_uecc_word_t ;
1930-
1931- #define HIGH_BIT_SET 0x8000000000000000U
1932- #define MG_UECC_WORD_BITS 64
1933- #define MG_UECC_WORD_BITS_SHIFT 6
1934- #define MG_UECC_WORD_BITS_MASK 0x03F
1935-
1936- #endif /* MG_UECC_WORD_SIZE */
1937-
1938- #endif /* _UECC_TYPES_H_ */
19391940// End of uecc BSD-2
19401941// portable8439 v1.0.1
19411942// Source: https://github.com/DavyLandman/portable8439
0 commit comments