FreeRDP
Loading...
Searching...
No Matches
lsa_proto.h
1
17
18#ifndef WINPR_SSPICLI_LSA_PROTO_H
19#define WINPR_SSPICLI_LSA_PROTO_H
20
21#include <winpr/wtypes.h>
22#include <winpr/stream.h>
23#include <winpr/ndr.h>
24
25/* Each message is one NDR type-serialized object ([MS-RPCE] 2.2.6, version 1, little-endian),
26 * framed as the [MS-RDPEAR] payloads are: the common and private headers, a top-level referent
27 * id, then a fixed envelope (type, flags, requestId) followed by the message's fields as NDR
28 * scalars, byte buffers being conformant arrays (UINT32 count, then the bytes). The transport
29 * (lsa_transport) prepends the UINT32 frame length; this codec produces and consumes the payload
30 * without it. */
31
32#define LSA_PROTO_VERSION_MAJOR 1
33#define LSA_PROTO_VERSION_MINOR 0
34
35/* Stream framing cap, also the largest LsaCallAuthenticationPackage buffer. */
36#define LSA_PROTO_MAX_FRAME (1024UL * 1024UL)
37
38typedef enum
39{
40 LSA_MSG_HELLO = 1,
41 LSA_MSG_LOOKUP_PACKAGE = 2,
42 LSA_MSG_CALL_PACKAGE = 3,
43 /* TSSSP SSPI proxy: the daemon runs the CredSSP exchange on the client's behalf. */
44 SSPI_MSG_ACQUIRE_CRED = 17,
45 SSPI_MSG_FREE_CRED = 18,
46 SSPI_MSG_ISC = 19,
47 SSPI_MSG_DELETE_CTX = 20
48} LSA_MSG_TYPE;
49
50#define LSA_MSG_FLAG_RESPONSE 0x0001
51#define LSA_MSG_FLAG_ERROR 0x0002
52
53typedef struct
54{
55 UINT16 type;
56 UINT16 flags;
57 UINT32 requestId;
59
60/* Writer: owns the output stream and the encoder between init and finish. */
61typedef struct
62{
63 wStream* s;
64 WinPrNdrEncoder* enc;
66
67/* Reader: borrows the framed stream; object is a view of the serialized object in it. */
68typedef struct
69{
70 WinPrNdrDecoder* dec;
71 wStream object;
73
74#ifdef __cplusplus
75extern "C"
76{
77#endif
78
79 /* Start a message: allocates the stream and writes the envelope. On success the caller
80 * writes fields, then calls lsa_proto_writer_finish. */
81 WINPR_ATTR_NODISCARD
82 BOOL lsa_proto_writer_init(LsaProtoWriter* w, const LSA_MSG_HDR* hdr);
83
84 /* Hand back the framed bytes (payload, without the transport length prefix). The writer is
85 * released either way. */
86 WINPR_ATTR_NODISCARD
87 BOOL lsa_proto_writer_finish(LsaProtoWriter* w, wStream** framed);
88
89 void lsa_proto_writer_abort(LsaProtoWriter* w);
90
91 WINPR_ATTR_NODISCARD BOOL lsa_proto_write_u16(LsaProtoWriter* w, UINT16 v);
92 WINPR_ATTR_NODISCARD BOOL lsa_proto_write_u32(LsaProtoWriter* w, UINT32 v);
93 WINPR_ATTR_NODISCARD BOOL lsa_proto_write_u64(LsaProtoWriter* w, UINT64 v);
94 WINPR_ATTR_NODISCARD BOOL lsa_proto_write_blob(LsaProtoWriter* w, const BYTE* data, UINT32 len);
95
96 /* Parse a framed message (without the transport length prefix): reads the envelope into hdr.
97 * Fields are then read from the reader. */
98 WINPR_ATTR_NODISCARD
99 BOOL lsa_proto_reader_init(LsaProtoReader* r, wStream* framed, LSA_MSG_HDR* hdr);
100
101 void lsa_proto_reader_done(LsaProtoReader* r);
102
103 WINPR_ATTR_NODISCARD BOOL lsa_proto_read_u16(LsaProtoReader* r, UINT16* v);
104 WINPR_ATTR_NODISCARD BOOL lsa_proto_read_u32(LsaProtoReader* r, UINT32* v);
105 WINPR_ATTR_NODISCARD BOOL lsa_proto_read_u64(LsaProtoReader* r, UINT64* v);
106
107 /* Read a byte buffer (a conformant array), allocating *data (caller frees). An empty buffer
108 * yields *data == nullptr, *len == 0. */
109 WINPR_ATTR_NODISCARD
110 BOOL lsa_proto_read_blob(LsaProtoReader* r, BYTE** data, UINT32* len);
111
112#ifdef __cplusplus
113}
114#endif
115
116#endif /* WINPR_SSPICLI_LSA_PROTO_H */
NDR encoder and decoder ([C706] chapter 14, [MS-RPCE] 2.2.5 and 2.2.6).