Home | History | Annotate | Line # | Download | only in internal
      1 /*
      2  * Copyright 2024 The OpenSSL Project Authors. All Rights Reserved.
      3  *
      4  * Licensed under the Apache License 2.0 (the "License").  You may not use
      5  * this file except in compliance with the License.  You can obtain a copy
      6  * in the file LICENSE in the source distribution or at
      7  * https://www.openssl.org/source/license.html
      8  */
      9 
     10 #ifndef OSSL_INTERNAL_TO_HEX_H
     11 #define OSSL_INTERNAL_TO_HEX_H
     12 #pragma once
     13 
     14 static ossl_inline size_t to_hex(char *buf, uint8_t n, const char hexdig[17])
     15 {
     16     *buf++ = hexdig[(n >> 4) & 0xf];
     17     *buf = hexdig[n & 0xf];
     18     return 2;
     19 }
     20 
     21 static ossl_inline size_t ossl_to_lowerhex(char *buf, uint8_t n)
     22 {
     23     static const char hexdig[] = "0123456789abcdef";
     24 
     25     return to_hex(buf, n, hexdig);
     26 }
     27 #endif
     28