LCOV - code coverage report
Current view: top level - waltz/tls - fd_tls_asn1.c (source / functions) Hit Total Coverage
Test: cov.lcov Lines: 7 9 77.8 %
Date: 2024-11-13 11:58:15 Functions: 1 1 100.0 %

          Line data    Source code
       1             : #include "fd_tls_asn1.h"
       2             : 
       3             : const uchar fd_asn1_ed25519_pubkey_prefix[] =
       4             :   { /* SEQUENCE (2) */
       5             :     0x30, 0x2A,
       6             :     /*   SEQUENCE (1) */
       7             :     0x30, 0x05,
       8             :     /*     OBJECT IDENTIFIER  1.3.101.112 */
       9             :     0x06, 0x03, 0x2B, 0x65, 0x70,
      10             :     /*   BIT STRING */
      11             :     0x03, 0x21, 0x00 };
      12             : 
      13             : /* Example:
      14             :    https://lapo.it/asn1js/#MCowBQYDK2VwAyEAGb9ECWmEzf6FQbrBZ9w7lshQhqowtrbLDFw4rXAxZuE */
      15             : 
      16             : void const *
      17             : fd_ed25519_public_key_from_asn1( uchar const * buf,
      18        6018 :                                  ulong         sz ) {
      19             : 
      20        6018 :   void const * prefix   =         fd_asn1_ed25519_pubkey_prefix;
      21        6018 :   ulong        prefix_sz = sizeof(fd_asn1_ed25519_pubkey_prefix);
      22             : 
      23        6018 :   if( FD_UNLIKELY( sz!=prefix_sz+32UL ) )
      24           0 :     return NULL;
      25             : 
      26        6018 :   if( FD_UNLIKELY( 0!=memcmp( buf, prefix, prefix_sz ) ) )
      27           0 :     return NULL;
      28             : 
      29        6018 :   return buf+prefix_sz;
      30        6018 : }

Generated by: LCOV version 1.14