pem_common.c
Go to the documentation of this file.
1 /**
2  * @file pem_common.c
3  * @brief PEM common definitions
4  *
5  * @section License
6  *
7  * SPDX-License-Identifier: GPL-2.0-or-later
8  *
9  * Copyright (C) 2010-2025 Oryx Embedded SARL. All rights reserved.
10  *
11  * This file is part of CycloneCRYPTO Open.
12  *
13  * This program is free software; you can redistribute it and/or
14  * modify it under the terms of the GNU General Public License
15  * as published by the Free Software Foundation; either version 2
16  * of the License, or (at your option) any later version.
17  *
18  * This program is distributed in the hope that it will be useful,
19  * but WITHOUT ANY WARRANTY; without even the implied warranty of
20  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21  * GNU General Public License for more details.
22  *
23  * You should have received a copy of the GNU General Public License
24  * along with this program; if not, write to the Free Software Foundation,
25  * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
26  *
27  * @author Oryx Embedded SARL (www.oryx-embedded.com)
28  * @version 2.5.0
29  **/
30 
31 //Switch to the appropriate trace level
32 #define TRACE_LEVEL CRYPTO_TRACE_LEVEL
33 
34 //Dependencies
35 #include "core/crypto.h"
36 #include "pkix/pem_common.h"
37 #include "encoding/oid.h"
38 #include "encoding/base64.h"
40 #include "debug.h"
41 
42 //Check crypto library configuration
43 #if (PEM_SUPPORT == ENABLED)
44 
45 
46 /**
47  * @brief Convert PEM container to ASN.1 format
48  * @param[in] input PEM container to decode
49  * @param[in] inputLen Length of the PEM container to decode
50  * @param[in] label Label indicating the type of data
51  * @param[out] output ASN.1 data (optional parameter)
52  * @param[out] outputLen Length of the ASN.1 data
53  * @param[out] header PEM encapsulated header (optional parameter)
54  * @param[out] consumed Total number of characters that have been consumed
55  * (optional parameter)
56  **/
57 
58 error_t pemDecodeFile(const char_t *input, size_t inputLen, const char_t *label,
59  uint8_t *output, size_t *outputLen, PemHeader *header, size_t *consumed)
60 {
61  error_t error;
62  int_t i;
63  int_t j;
64  size_t n;
65 
66  //Check parameters
67  if(input == NULL || label == NULL || outputLen == NULL)
69 
70  //The PEM container begins with a "-----BEGIN " line
71  i = pemFindTag(input, inputLen, "-----BEGIN ", label, "-----");
72  //Pre-encapsulation boundary not found?
73  if(i < 0)
74  return ERROR_END_OF_FILE;
75 
76  //Skip the pre-encapsulation boundary
77  i += osStrlen("-----BEGIN -----") + osStrlen(label);
78 
79  //The PEM container ends with a "-----END " line
80  j = pemFindTag(input + i, inputLen - i, "-----END ", label, "-----");
81  //Post-encapsulation boundary not found?
82  if(j < 0)
83  return ERROR_INVALID_SYNTAX;
84 
85  //Parse PEM encapsulated header
86  error = pemParseHeader(input + i, j, header, &n);
87  //Any error to report?
88  if(error)
89  return error;
90 
91  //The contents of the PEM file is Base64-encoded
92  error = base64Decode(input + i + n, j - n, output, outputLen);
93  //Failed to decode the file?
94  if(error)
95  return error;
96 
97  //Sanity check
98  if(*outputLen == 0)
99  return ERROR_INVALID_SYNTAX;
100 
101  //The last parameter is optional
102  if(consumed != NULL)
103  {
104  //Total number of characters that have been consumed
105  *consumed = i + j + osStrlen("-----END -----") + osStrlen(label);
106  }
107 
108  //Successful processing
109  return NO_ERROR;
110 }
111 
112 
113 /**
114  * @brief Convert ASN.1 data to PEM encoding
115  * @param[in] input ASN.1 data to encode
116  * @param[in] inputLen Length of the ASN.1 data to encode
117  * @param[in] label Label indicating the type of data
118  * @param[out] output PEM container (optional parameter)
119  * @param[out] outputLen Length of the PEM container
120  **/
121 
122 error_t pemEncodeFile(const void *input, size_t inputLen, const char_t *label,
123  char_t *output, size_t *outputLen)
124 {
125  size_t n;
126  size_t labelLen;
127  char_t *p;
128 
129  //Check parameters
130  if(input == NULL || label == NULL || outputLen == NULL)
132 
133  //Calculate the length of the label
134  labelLen = osStrlen(label);
135 
136  //Generators must wrap the Base64-encoded lines so that each line consists
137  //of exactly 64 characters except for the final line, which will encode the
138  //remainder of the data (refer to RFC 7468, section 2)
139  base64EncodeMultiline(input, inputLen, output, &n, 64);
140 
141  //If the output parameter is NULL, then the function calculates the length
142  //of the resulting PEM file without copying any data
143  if(output != NULL)
144  {
145  //A PEM file starts with a pre-encapsulation boundary
146  p = output + osStrlen("-----BEGIN -----\r\n") + labelLen;
147 
148  //Make room for the pre-encapsulation boundary
149  osMemmove(p, output, n);
150 
151  //The type of data encoded is labeled depending on the type label in
152  //the "-----BEGIN " line (refer to RFC 7468, section 2)
153  osStrcpy(output, "-----BEGIN ");
154  osStrcpy(output + 11, label);
155  osMemcpy(p - 7, "-----\r\n", 7);
156 
157  //Generators must put the same label on the "-----END " line as the
158  //corresponding "-----BEGIN " line
159  osStrcpy(p + n, "\r\n-----END ");
160  osStrcpy(p + n + 11, label);
161  osStrcpy(p + n + labelLen + 11, "-----\r\n");
162  }
163 
164  //Consider the length of the PEM encapsulation boundaries
165  n += osStrlen("-----BEGIN -----\r\n") + labelLen;
166  n += osStrlen("\r\n-----END -----\r\n") + labelLen;
167 
168  //Total number of bytes that have been written
169  *outputLen = n;
170 
171  //Successful processing
172  return NO_ERROR;
173 }
174 
175 
176 /**
177  * @brief Parse PEM encapsulated header
178  * @param[in] input PEM message body
179  * @param[in] inputLen Length of the PEM message body
180  * @param[in] header PEM encapsulated header (optional parameter)
181  * @param[out] consumed Total number of bytes that have been consumed
182  * @return Error code
183  **/
184 
185 error_t pemParseHeader(const char_t *input, size_t inputLen,
186  PemHeader *header, size_t *consumed)
187 {
188  size_t n;
189  const char_t *end;
190  PemString line;
191 
192  //The header parameter is optional
193  if(header != NULL)
194  {
195  //Clear header fields
196  osMemset(header, 0, sizeof(PemHeader));
197  }
198 
199  //Total number of bytes that have been consumed
200  *consumed = 0;
201 
202  //Parse PEM encapsulated header
203  while(1)
204  {
205  //Extract a line from the PEM message body
206  end = osMemchr(input, '\n', inputLen);
207  //No end of line character detected?
208  if(end == NULL)
209  break;
210 
211  //Calculate the length of the line
212  n = end - input + 1;
213 
214  //Point to the current line
215  line.value = input;
216  line.length = n;
217 
218  //Removes all leading and trailing whitespace from a string
219  pemTrimWhitespace(&line);
220 
221  //Discard empty lines
222  if(!pemCompareString(&line, ""))
223  {
224  //Each header field consists of a field name followed by a colon,
225  //optional leading whitespace, and the field value
226  if(pemFindChar(&line, ':') >= 0)
227  {
228  //Parse header field
229  pemParseHeaderField(&line, header);
230  }
231  else
232  {
233  //We are done
234  break;
235  }
236  }
237 
238  //Point to the next line
239  input += n;
240  inputLen -= n;
241  *consumed += n;
242  }
243 
244  //Sucessful processing
245  return NO_ERROR;
246 }
247 
248 
249 /**
250  * @brief Parse header field
251  * @param[in] line Header field
252  * @param[in] header PEM encapsulated header (optional parameter)
253  **/
254 
256 {
257  PemString name;
258  PemString arg1;
259  PemString arg2;
260 
261  //Each header field consists of a field name followed by a colon,
262  //optional leading whitespace, and the field value
263  pemTokenizeString(line, ':', &name);
264 
265  //Removes all leading and trailing whitespace from the name
267 
268  //Check header field name
269  if(pemCompareString(&name, "Proc-Type"))
270  {
271  //The "Proc-Type" encapsulated header field, required for all PEM
272  //messages, identifies the type of processing performed on the
273  //transmitted message (refer to RFC 1421, section 4.6.1.1)
274  if(pemTokenizeString(line, ',', &arg1) &&
275  pemTokenizeString(line, ',', &arg2))
276  {
277  //Removes all leading and trailing whitespace characters
278  pemTrimWhitespace(&arg1);
279  pemTrimWhitespace(&arg2);
280 
281  //Save arguments
282  if(header != NULL)
283  {
284  header->procType.version = arg1;
285  header->procType.type = arg2;
286  }
287  }
288  }
289  else if(pemCompareString(&name, "DEK-Info"))
290  {
291  //The "DEK-Info" encapsulated header field identifies the message text
292  //encryption algorithm and mode, and also carries the IV used for message
293  //encryption (refer to RFC 1421, section 4.6.1.3)
294  if(pemTokenizeString(line, ',', &arg1) &&
295  pemTokenizeString(line, ',', &arg2))
296  {
297  //Removes all leading and trailing whitespace characters
298  pemTrimWhitespace(&arg1);
299  pemTrimWhitespace(&arg2);
300 
301  //Save arguments
302  if(header != NULL)
303  {
304  header->dekInfo.algo = arg1;
305  header->dekInfo.iv = arg2;
306  }
307  }
308  }
309  else
310  {
311  //Unknown header field name
312  }
313 }
314 
315 
316 /**
317  * @brief Search a string for a given tag
318  * @param[in] input String to search
319  * @param[in] inputLen Length of the string to search
320  * @param[in] tag1 First part of the tag (NULL-terminated string)
321  * @param[in] tag2 Second part of the tag (NULL-terminated string)
322  * @param[in] tag3 Third part of the tag (NULL-terminated string)
323  * @return The index of the first occurrence of the tag in the string,
324  * or -1 if the tag does not appear in the string
325  **/
326 
327 int_t pemFindTag(const char_t *input, size_t inputLen, const char_t *tag1,
328  const char_t *tag2, const char_t *tag3)
329 {
330  size_t i;
331  size_t j;
332  size_t n1;
333  size_t n2;
334  size_t n3;
335  int_t index;
336 
337  //Initialize index
338  index = -1;
339 
340  //Calculate the length of the tag
341  n1 = osStrlen(tag1);
342  n2 = osStrlen(tag2);
343  n3 = osStrlen(tag3);
344 
345  //Parse input string
346  for(i = 0; (i + n1 + n2 + n3) <= inputLen; i++)
347  {
348  //Compare current substring with the given tag
349  for(j = 0; j < (n1 + n2 + n3); j++)
350  {
351  if(j < n1)
352  {
353  if(input[i + j] != tag1[j])
354  break;
355  }
356  else if(j < (n1 + n2))
357  {
358  if(input[i + j] != tag2[j - n1])
359  break;
360  }
361  else
362  {
363  if(input[i + j] != tag3[j - n1 - n2])
364  break;
365  }
366  }
367 
368  //Check whether the tag has been found
369  if(j == (n1 + n2 + n3))
370  {
371  index = i;
372  break;
373  }
374  }
375 
376  //Return the index of the first occurrence of the tag in the string
377  return index;
378 }
379 
380 
381 /**
382  * @brief Search a string for a given character
383  * @param[in] s String to be scanned
384  * @param[in] c Character to be searched
385  * @return Index of the first occurrence of the character
386  **/
387 
389 {
390  int_t index;
391  char_t *p;
392 
393  //Search the string for the specified character
394  p = osMemchr(s->value, c, s->length);
395 
396  //Character found?
397  if(p != NULL)
398  {
399  index = p - s->value;
400  }
401  else
402  {
403  index = -1;
404  }
405 
406  //Return the index of the first occurrence of the character
407  return index;
408 }
409 
410 
411 /**
412  * @brief Compare a string against the supplied value
413  * @param[in] string String to be compared
414  * @param[in] value NULL-terminated string
415  * @return Comparison result
416  **/
417 
419 {
420  bool_t res;
421  size_t n;
422 
423  //Initialize flag
424  res = FALSE;
425 
426  //Valid NULL-terminated string?
427  if(value != NULL)
428  {
429  //Determine the length of the string
430  n = osStrlen(value);
431 
432  //Check the length of the string
433  if(string->value != NULL && string->length == n)
434  {
435  //Perform string comparison
436  if(osStrncmp(string->value, value, n) == 0)
437  {
438  res = TRUE;
439  }
440  }
441  }
442 
443  //Return comparison result
444  return res;
445 }
446 
447 
448 /**
449  * @brief Split a string into tokens
450  * @param[in,out] s String to be split
451  * @param[in] c Delimiter character
452  * @param[out] token Resulting token
453  * @return TRUE if a token has been found, else FALSE
454  **/
455 
457 {
458  char_t *p;
459  size_t n;
460  bool_t found;
461 
462  //Search the string for the specified delimiter character
463  p = osMemchr(s->value, c, s->length);
464 
465  //Delimiter character found?
466  if(p != NULL)
467  {
468  //Retrieve the length of the token
469  n = p - s->value;
470 
471  //Extract the token from the string
472  token->value = s->value;
473  token->length = n;
474 
475  //Point to the next token
476  s->value += n + 1;
477  s->length -= n + 1;
478 
479  //A token has been found
480  found = TRUE;
481  }
482  else if(s->length > 0)
483  {
484  //This is the last token
485  token->value = s->value;
486  token->length = s->length;
487 
488  //A token has been found
489  found = TRUE;
490  }
491  else
492  {
493  //The end of the string has been reached
494  found = FALSE;
495  }
496 
497  //Return TRUE if a token has been found, else FALSE
498  return found;
499 }
500 
501 
502 /**
503  * @brief Removes all leading and trailing whitespace from a string
504  * @param[in] s String to be trimmed
505  **/
506 
508 {
509  //Trim whitespace from the beginning
510  while(s->length > 0 && osIsspace(s->value[0]))
511  {
512  s->value++;
513  s->length--;
514  }
515 
516  //Trim whitespace from the end
517  while(s->length > 0 && osIsspace(s->value[s->length - 1]))
518  {
519  s->length--;
520  }
521 }
522 
523 
524 /**
525  * @brief Get the cipher algorithm to be used for PEM encryption/decryption
526  * @param[in] algo Encryption algorithm
527  * @return Cipher algorithm
528  **/
529 
531 {
532  const CipherAlgo *cipherAlgo;
533 
534 #if (PEM_DES_SUPPORT == ENABLED && DES_SUPPORT == ENABLED)
535  //DES-CBC algorithm identifier?
536  if(pemCompareString(algo, "DES-CBC"))
537  {
538  cipherAlgo = DES_CIPHER_ALGO;
539  }
540  else
541 #endif
542 #if (PEM_3DES_SUPPORT == ENABLED && DES3_SUPPORT == ENABLED)
543  //DES-EDE3-CBC algorithm identifier?
544  if(pemCompareString(algo, "DES-EDE3-CBC"))
545  {
546  cipherAlgo = DES3_CIPHER_ALGO;
547  }
548  else
549 #endif
550 #if (PEM_AES_SUPPORT == ENABLED && AES_SUPPORT == ENABLED)
551  //AES-128-CBC algorithm identifier?
552  if(pemCompareString(algo, "AES-128-CBC"))
553  {
554  cipherAlgo = AES_CIPHER_ALGO;
555  }
556  //AES-192-CBC algorithm identifier?
557  else if(pemCompareString(algo, "AES-192-CBC"))
558  {
559  cipherAlgo = AES_CIPHER_ALGO;
560  }
561  //AES-256-CBC algorithm identifier?
562  else if(pemCompareString(algo, "AES-256-CBC"))
563  {
564  cipherAlgo = AES_CIPHER_ALGO;
565  }
566  else
567 #endif
568 #if (PEM_CAMELLIA_SUPPORT == ENABLED && CAMELLIA_SUPPORT == ENABLED)
569  //Camellia-128-CBC algorithm identifier?
570  if(pemCompareString(algo, "CAMELLIA-128-CBC"))
571  {
572  cipherAlgo = CAMELLIA_CIPHER_ALGO;
573  }
574  //Camellia-192-CBC algorithm identifier?
575  else if(pemCompareString(algo, "CAMELLIA-192-CBC"))
576  {
577  cipherAlgo = CAMELLIA_CIPHER_ALGO;
578  }
579  //Camellia-256-CBC algorithm identifier?
580  else if(pemCompareString(algo, "CAMELLIA-256-CBC"))
581  {
582  cipherAlgo = CAMELLIA_CIPHER_ALGO;
583  }
584  else
585 #endif
586 #if (PEM_ARIA_SUPPORT == ENABLED && ARIA_SUPPORT == ENABLED)
587  //ARIA-128-CBC algorithm identifier?
588  if(pemCompareString(algo, "ARIA-128-CBC"))
589  {
590  cipherAlgo = ARIA_CIPHER_ALGO;
591  }
592  //ARIA-192-CBC algorithm identifier?
593  else if(pemCompareString(algo, "ARIA-192-CBC"))
594  {
595  cipherAlgo = ARIA_CIPHER_ALGO;
596  }
597  //ARIA-256-CBC algorithm identifier?
598  else if(pemCompareString(algo, "ARIA-256-CBC"))
599  {
600  cipherAlgo = ARIA_CIPHER_ALGO;
601  }
602  else
603 #endif
604 #if (PEM_SM4_SUPPORT == ENABLED && SM4_SUPPORT == ENABLED)
605  //SM4-CBC algorithm identifier?
606  if(pemCompareString(algo, "SM4-CBC"))
607  {
608  cipherAlgo = SM4_CIPHER_ALGO;
609  }
610  else
611 #endif
612  //Unknown algorithm identifier?
613  {
614  cipherAlgo = NULL;
615  }
616 
617  //Return the cipher algorithm that matches the specified OID
618  return cipherAlgo;
619 }
620 
621 
622 /**
623  * @brief Get the encryption key length to be used for PEM encryption/decryption
624  * @param[in] algo Encryption algorithm
625  * @return Encryption key length
626  **/
627 
629 {
630  uint_t keyLen;
631 
632 #if (PEM_DES_SUPPORT == ENABLED && DES_SUPPORT == ENABLED)
633  //DES-CBC algorithm algorithm?
634  if(pemCompareString(algo, "DES-CBC"))
635  {
636  keyLen = 8;
637  }
638  else
639 #endif
640 #if (PEM_3DES_SUPPORT == ENABLED && DES3_SUPPORT == ENABLED)
641  //DES-EDE3-CBC algorithm algorithm?
642  if(pemCompareString(algo, "DES-EDE3-CBC"))
643  {
644  keyLen = 24;
645  }
646  else
647 #endif
648 #if (PEM_AES_SUPPORT == ENABLED && AES_SUPPORT == ENABLED)
649  //AES-128-CBC algorithm algorithm?
650  if(pemCompareString(algo, "AES-128-CBC"))
651  {
652  keyLen = 16;
653  }
654  //AES-192-CBC algorithm algorithm?
655  else if(pemCompareString(algo, "AES-192-CBC"))
656  {
657  keyLen = 24;
658  }
659  //AES-256-CBC algorithm algorithm?
660  else if(pemCompareString(algo, "AES-256-CBC"))
661  {
662  keyLen = 32;
663  }
664  else
665 #endif
666 #if (PEM_CAMELLIA_SUPPORT == ENABLED && CAMELLIA_SUPPORT == ENABLED)
667  //Camellia-128-CBC algorithm identifier?
668  if(pemCompareString(algo, "CAMELLIA-128-CBC"))
669  {
670  keyLen = 16;
671  }
672  //Camellia-192-CBC algorithm identifier?
673  else if(pemCompareString(algo, "CAMELLIA-192-CBC"))
674  {
675  keyLen = 24;
676  }
677  //Camellia-256-CBC algorithm identifier?
678  else if(pemCompareString(algo, "CAMELLIA-256-CBC"))
679  {
680  keyLen = 32;
681  }
682  else
683 #endif
684 #if (PEM_ARIA_SUPPORT == ENABLED && ARIA_SUPPORT == ENABLED)
685  //ARIA-128-CBC algorithm identifier?
686  if(pemCompareString(algo, "ARIA-128-CBC"))
687  {
688  keyLen = 16;
689  }
690  //ARIA-192-CBC algorithm identifier?
691  else if(pemCompareString(algo, "ARIA-192-CBC"))
692  {
693  keyLen = 24;
694  }
695  //ARIA-256-CBC algorithm identifier?
696  else if(pemCompareString(algo, "ARIA-256-CBC"))
697  {
698  keyLen = 32;
699  }
700  else
701 #endif
702 #if (PEM_SM4_SUPPORT == ENABLED && SM4_SUPPORT == ENABLED)
703  //SM4-CBC algorithm identifier?
704  if(pemCompareString(algo, "SM4-CBC"))
705  {
706  keyLen = 16;
707  }
708  else
709 #endif
710  //Unknown algorithm identifier?
711  {
712  keyLen = 0;
713  }
714 
715  //Return the encryption key length that matches the specified OID
716  return keyLen;
717 }
718 
719 #endif
String representation.
Definition: pem_common.h:97
#define ARIA_CIPHER_ALGO
Definition: aria.h:40
int bool_t
Definition: compiler_port.h:61
uint_t pemGetKeyLength(const PemString *algo)
Get the encryption key length to be used for PEM encryption/decryption.
Definition: pem_common.c:628
signed int int_t
Definition: compiler_port.h:56
#define osMemchr(p, c, length)
Definition: os_port.h:162
OID (Object Identifier)
uint8_t p
Definition: ndp.h:300
error_t pemDecodeFile(const char_t *input, size_t inputLen, const char_t *label, uint8_t *output, size_t *outputLen, PemHeader *header, size_t *consumed)
Convert PEM container to ASN.1 format.
Definition: pem_common.c:58
#define TRUE
Definition: os_port.h:50
Collection of AEAD algorithms.
char_t name[]
#define osStrlen(s)
Definition: os_port.h:168
PEM common definitions.
void base64EncodeMultiline(const void *input, size_t inputLen, char_t *output, size_t *outputLen, size_t lineWidth)
Base64 multiline encoding.
Definition: base64.c:79
bool_t pemCompareString(const PemString *string, const char_t *value)
Compare a string against the supplied value.
Definition: pem_common.c:418
const uint8_t res[]
bool_t pemTokenizeString(PemString *s, char_t c, PemString *token)
Split a string into tokens.
Definition: pem_common.c:456
PEM encapsulated header.
Definition: pem_common.h:130
PemString version
Definition: pem_common.h:109
error_t base64Decode(const char_t *input, size_t inputLen, void *output, size_t *outputLen)
Base64 decoding algorithm.
Definition: base64.c:258
#define FALSE
Definition: os_port.h:46
void pemTrimWhitespace(PemString *s)
Removes all leading and trailing whitespace from a string.
Definition: pem_common.c:507
@ ERROR_INVALID_PARAMETER
Invalid parameter.
Definition: error.h:47
#define osMemcpy(dest, src, length)
Definition: os_port.h:144
error_t
Error codes.
Definition: error.h:43
PemDekInfo dekInfo
Definition: pem_common.h:132
error_t pemEncodeFile(const void *input, size_t inputLen, const char_t *label, char_t *output, size_t *outputLen)
Convert ASN.1 data to PEM encoding.
Definition: pem_common.c:122
#define osIsspace(c)
Definition: os_port.h:294
@ ERROR_END_OF_FILE
Definition: error.h:160
General definitions for cryptographic algorithms.
PemString iv
Definition: pem_common.h:121
#define CAMELLIA_CIPHER_ALGO
Definition: camellia.h:40
Base64 encoding scheme.
#define DES_CIPHER_ALGO
Definition: des.h:45
PemString type
Definition: pem_common.h:110
#define SM4_CIPHER_ALGO
Definition: sm4.h:45
PemString algo
Definition: pem_common.h:120
int_t pemFindChar(const PemString *s, char_t c)
Search a string for a given character.
Definition: pem_common.c:388
char char_t
Definition: compiler_port.h:55
uint8_t n
size_t length
Definition: pem_common.h:99
uint8_t value[]
Definition: tcp.h:376
Common interface for encryption algorithms.
Definition: crypto.h:1104
int_t pemFindTag(const char_t *input, size_t inputLen, const char_t *tag1, const char_t *tag2, const char_t *tag3)
Search a string for a given tag.
Definition: pem_common.c:327
const char_t * value
Definition: pem_common.h:98
#define AES_CIPHER_ALGO
Definition: aes.h:45
@ ERROR_INVALID_SYNTAX
Definition: error.h:68
error_t pemParseHeader(const char_t *input, size_t inputLen, PemHeader *header, size_t *consumed)
Parse PEM encapsulated header.
Definition: pem_common.c:185
uint8_t s
Definition: igmp_common.h:234
PemProcType procType
Definition: pem_common.h:131
#define osStrncmp(s1, s2, length)
Definition: os_port.h:180
#define DES3_CIPHER_ALGO
Definition: des3.h:46
void pemParseHeaderField(PemString *line, PemHeader *header)
Parse header field.
Definition: pem_common.c:255
unsigned int uint_t
Definition: compiler_port.h:57
#define osMemset(p, value, length)
Definition: os_port.h:138
#define osStrcpy(s1, s2)
Definition: os_port.h:210
@ NO_ERROR
Success.
Definition: error.h:44
uint8_t c
Definition: ndp.h:514
const CipherAlgo * pemGetCipherAlgo(const PemString *algo)
Get the cipher algorithm to be used for PEM encryption/decryption.
Definition: pem_common.c:530
Debugging facilities.
#define osMemmove(dest, src, length)
Definition: os_port.h:150
uint8_t token[]
Definition: coap_common.h:181