opcua_secureChannelLayer.h 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137
  1. /*
  2. * opcua_secureChannelLayer.h
  3. *
  4. * Created on: Dec 19, 2013
  5. * Author: opcua
  6. */
  7. #ifndef OPCUA_SECURECHANNELLAYER_H_
  8. #define OPCUA_SECURECHANNELLAYER_H_
  9. #include "opcua_advancedDatatypes.h"
  10. #include "opcua_encodingLayer.h"
  11. #include "opcua_connectionHelper.h"
  12. static const Int32 SL_HEADER_LENGTH = 0;
  13. typedef struct
  14. {
  15. UInt32 ServerProtocolVersion;
  16. SL_ChannelSecurityToken SecurityToken;
  17. UA_String ServerNonce;
  18. }SL_Response;
  19. typedef struct
  20. {
  21. UInt32 MessageType;
  22. Byte IsFinal;
  23. UInt32 MessageSize;
  24. UInt32 SecureChannelId;
  25. }SL_SecureConversationMessageHeader;
  26. typedef struct
  27. {
  28. UA_String SecurityPolicyUri;
  29. UA_String SenderCertificate;
  30. UA_String ReceiverThumbprint;
  31. }SL_AsymmetricAlgorithmSecurityHeader;
  32. typedef struct _SL_SequenceHeader
  33. {
  34. UInt32 SequenceNumber;
  35. UInt32 RequestId;
  36. }SL_SequenceHeader;
  37. /*
  38. * optional, only if there is encryption present
  39. */
  40. typedef struct _SL_AsymmetricAlgorithmSecurityFooter
  41. {
  42. Byte PaddingSize;
  43. Byte *Padding;
  44. UInt32 SignatureSize;
  45. Byte *Signature;
  46. }SL_AsymmetricAlgorithmSecurityFooter;
  47. /*
  48. typedef struct _SL_ResponseHeader
  49. {
  50. UA_DateTime timestamp;
  51. IntegerId requestHandle;
  52. UA_StatusCode serviceResult;
  53. UA_DiagnosticInfo serviceDiagnostics;
  54. UA_String *stringTable;
  55. UInt32 stringTableLength;
  56. UA_ExtensionObject additionalHeader;
  57. }SL_ResponseHeader;
  58. */
  59. Int32 SL_openSecureChannel_responseMessage_get(UA_connection *connection,
  60. SL_Response *response, Int32* sizeInOut);
  61. /**
  62. *
  63. * @param connection
  64. * @param rawMessage
  65. * @param pos
  66. * @param SC_Header
  67. * @return
  68. */
  69. Int32 decodeSCMHeader(AD_RawMessage *rawMessage,Int32 *pos,
  70. SL_SecureConversationMessageHeader* SC_Header);
  71. /**
  72. *
  73. * @param SC_Header
  74. * @param pos
  75. * @param rawMessage
  76. * @return
  77. */
  78. Int32 encodeSCMHeader(SL_SecureConversationMessageHeader *SC_Header,
  79. Int32 *pos,AD_RawMessage *rawMessage);
  80. /**
  81. *
  82. * @param rawMessage
  83. * @param pos
  84. * @param SequenceHeader
  85. * @return
  86. */
  87. Int32 decodeSequenceHeader(AD_RawMessage *rawMessage, Int32 *pos,
  88. SL_SequenceHeader *sequenceHeader);
  89. /**
  90. *
  91. * @param sequenceHeader
  92. * @param pos
  93. * @param dstRawMessage
  94. * @return
  95. */
  96. Int32 encodeSequenceHeader(SL_SequenceHeader *sequenceHeader,Int32 *pos,
  97. AD_RawMessage *dstRawMessage);
  98. /**
  99. *
  100. * @param rawMessage
  101. * @param pos
  102. * @param AAS_Header
  103. * @return
  104. */
  105. Int32 decodeAASHeader(AD_RawMessage *rawMessage, Int32 *pos,
  106. SL_AsymmetricAlgorithmSecurityHeader* AAS_Header);
  107. /**
  108. *
  109. * @param AAS_Header
  110. * @param pos
  111. * @param dstRawMessage
  112. * @return
  113. */
  114. Int32 encodeAASHeader(SL_AsymmetricAlgorithmSecurityHeader *AAS_Header,
  115. Int32 *pos, AD_RawMessage* dstRawMessage);
  116. #endif /* OPCUA_SECURECHANNELLAYER_H_ */