You can not select more than 25 topics Topics must start with a chinese character,a letter or number, can include dashes ('-') and can be up to 35 characters long.

securecutil.c 1.9 kB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  1. /**
  2. * Copyright 2020 Huawei Technologies Co., Ltd
  3. *
  4. * Licensed under the Apache License, Version 2.0 (the "License");
  5. * you may not use this file except in compliance with the License.
  6. * You may obtain a copy of the License at
  7. *
  8. * http://www.apache.org/licenses/LICENSE-2.0
  9. *
  10. * Unless required by applicable law or agreed to in writing, software
  11. * distributed under the License is distributed on an "AS IS" BASIS,
  12. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  13. * See the License for the specific language governing permissions and
  14. * limitations under the License.
  15. */
  16. /* Avoid duplicate header files,not include securecutil.h */
  17. #include "securecutil.h"
  18. #if defined(ANDROID) && (SECUREC_HAVE_WCTOMB || SECUREC_HAVE_MBTOWC)
  19. #include <wchar.h>
  20. #if SECUREC_HAVE_WCTOMB
  21. /*
  22. * Convert wide characters to narrow multi-bytes
  23. */
  24. int wctomb(char *s, wchar_t wc)
  25. {
  26. return wcrtomb(s, wc, NULL);
  27. }
  28. #endif
  29. #if SECUREC_HAVE_MBTOWC
  30. /*
  31. * Converting narrow multi-byte characters to wide characters
  32. */
  33. int mbtowc(wchar_t *pwc, const char *s, size_t n)
  34. {
  35. return mbrtowc(pwc, s, n, NULL);
  36. }
  37. #endif
  38. #endif
  39. /* high Num << 8 | num of SPC Ver */
  40. #define SECUREC_C_VERSION (0x5 << 8)
  41. #define SECUREC_SPC_VERSION 7
  42. #define SECUREC_VERSION_STR "Huawei Secure C V100R001C01SPC007B002"
  43. /* SPC verNumber<->verStr like:
  44. * 0X201<->C01
  45. * 0X202<->SPC001 Redefine numbers after this version
  46. * 0X502<->SPC002
  47. * 0X503<->SPC003
  48. * ...
  49. * 0X50a<->SPC010
  50. * 0X50b<->SPC011
  51. * ...
  52. */
  53. /* CP verNumber<->verStr like:
  54. * 0X601<->CP0001
  55. * 0X602<->CP0002
  56. * ...
  57. */
  58. const char *GetHwSecureCVersion(unsigned short *verNumber)
  59. {
  60. if (verNumber != NULL) {
  61. *verNumber = (unsigned short)(SECUREC_C_VERSION | SECUREC_SPC_VERSION);
  62. }
  63. return SECUREC_VERSION_STR;
  64. }
  65. #if SECUREC_IN_KERNEL
  66. EXPORT_SYMBOL(GetHwSecureCVersion);
  67. #endif