rc2_local.h 3.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  1. /*
  2. * Copyright 1995-2023 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. #undef c2l
  10. #define c2l(c,l) (l =((unsigned long)(*((c)++))) , \
  11. l|=((unsigned long)(*((c)++)))<< 8L, \
  12. l|=((unsigned long)(*((c)++)))<<16L, \
  13. l|=((unsigned long)(*((c)++)))<<24L)
  14. /* NOTE - c is not incremented as per c2l */
  15. #undef c2ln
  16. #define c2ln(c,l1,l2,n) { \
  17. c+=n; \
  18. l1=l2=0; \
  19. switch (n) { \
  20. case 8: l2 =((unsigned long)(*(--(c))))<<24L; \
  21. /* fall through */ \
  22. case 7: l2|=((unsigned long)(*(--(c))))<<16L; \
  23. /* fall through */ \
  24. case 6: l2|=((unsigned long)(*(--(c))))<< 8L; \
  25. /* fall through */ \
  26. case 5: l2|=((unsigned long)(*(--(c)))); \
  27. /* fall through */ \
  28. case 4: l1 =((unsigned long)(*(--(c))))<<24L; \
  29. /* fall through */ \
  30. case 3: l1|=((unsigned long)(*(--(c))))<<16L; \
  31. /* fall through */ \
  32. case 2: l1|=((unsigned long)(*(--(c))))<< 8L; \
  33. /* fall through */ \
  34. case 1: l1|=((unsigned long)(*(--(c)))); \
  35. } \
  36. }
  37. #undef l2c
  38. #define l2c(l,c) (*((c)++)=(unsigned char)(((l) )&0xff), \
  39. *((c)++)=(unsigned char)(((l)>> 8L)&0xff), \
  40. *((c)++)=(unsigned char)(((l)>>16L)&0xff), \
  41. *((c)++)=(unsigned char)(((l)>>24L)&0xff))
  42. /* NOTE - c is not incremented as per l2c */
  43. #undef l2cn
  44. #define l2cn(l1,l2,c,n) { \
  45. c+=n; \
  46. switch (n) { \
  47. case 8: *(--(c))=(unsigned char)(((l2)>>24L)&0xff); \
  48. /* fall through */ \
  49. case 7: *(--(c))=(unsigned char)(((l2)>>16L)&0xff); \
  50. /* fall through */ \
  51. case 6: *(--(c))=(unsigned char)(((l2)>> 8L)&0xff); \
  52. /* fall through */ \
  53. case 5: *(--(c))=(unsigned char)(((l2) )&0xff); \
  54. /* fall through */ \
  55. case 4: *(--(c))=(unsigned char)(((l1)>>24L)&0xff); \
  56. /* fall through */ \
  57. case 3: *(--(c))=(unsigned char)(((l1)>>16L)&0xff); \
  58. /* fall through */ \
  59. case 2: *(--(c))=(unsigned char)(((l1)>> 8L)&0xff); \
  60. /* fall through */ \
  61. case 1: *(--(c))=(unsigned char)(((l1) )&0xff); \
  62. } \
  63. }