Debian Codegraph @

winpr/libwinpr/sspi/sspi_gss.c

raw symbols SCIP
1 /**
2 * FreeRDP: A Remote Desktop Protocol Implementation
3 * Generic Security Service Application Program Interface (GSSAPI)
4 *
5 * Copyright 2015 ANSSI, Author Thomas Calderon
6 * Copyright 2015 Marc-Andre Moreau <[email protected]>
7 * Copyright 2017 Dorian Ducournau <[email protected]>
8 *
9 * Licensed under the Apache License, Version 2.0 (the "License");
10 * you may not use this file except in compliance with the License.
11 * You may obtain a copy of the License at
12 *
13 * http://www.apache.org/licenses/LICENSE-2.0
14 *
15 * Unless required by applicable law or agreed to in writing, software
16 * distributed under the License is distributed on an "AS IS" BASIS,
17 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
18 * See the License for the specific language governing permissions and
19 * limitations under the License.
20 */
21
22 #include <winpr/crt.h>cxx . . $ `<file>/winpr/include/winpr/crt.h`/
23 #include <winpr/assert.h>cxx . . $ `<file>/winpr/include/winpr/assert.h`/
24 #include <winpr/endian.h>cxx . . $ `<file>/winpr/include/winpr/endian.h`/
25 #include <winpr/asn1.h>cxx . . $ `<file>/winpr/include/winpr/asn1.h`/
26 #include <winpr/stream.h>cxx . . $ `<file>/winpr/include/winpr/stream.h`/
27
28 #include "sspi_gss.h"cxx . . $ `<file>/winpr/libwinpr/sspi/sspi_gss.h`/
29
30 BOOLcxx . . $ BOOL# sspi_gss_wrap_tokencxx . . $ sspi_gss_wrap_token(aa1528adb66fe894).(SecBuffercxx . . $ SecBuffer#* buf, const WinPrAsn1_OIDcxx . . $ WinPrAsn1_OID#* oid, uint16_tcxx . . $ uint16_t# tok_id,
31 const sspi_gss_datacxx . . $ sspi_gss_data#* token)
32 {
33 WinPrAsn1Encodercxx . . $ WinPrAsn1Encoder#* enc = nullptrcxx . . $ `winpr/include/winpr/platform.h:88:9`!;
34 BYTEcxx . . $ BYTE# tok_id_buf[2];
35 WinPrAsn1_MemoryChunkcxx . . $ WinPrAsn1_MemoryChunk# mc = { 2, tok_id_buf };
36 wStreamcxx . . $ wStream# s;
37 size_tcxx . . $ size_t# len = 0;
38 BOOLcxx . . $ BOOL# ret = FALSEcxx . . $ `winpr/include/winpr/wtypes.h:122:9`!;
39
40 WINPR_ASSERTcxx . . $ `winpr/include/winpr/assert-api.h:76:9`!(buf);
41 WINPR_ASSERTcxx . . $ `winpr/include/winpr/assert-api.h:76:9`!(oid);
42 WINPR_ASSERTcxx . . $ `winpr/include/winpr/assert-api.h:76:9`!(token);
43
44 winpr_Data_Write_UINT16_BEcxx . . $ winpr_Data_Write_UINT16_BE(7ff71eb16271959b).(tok_id_buf, tok_id);
45
46 enc = WinPrAsn1Encoder_Newcxx . . $ WinPrAsn1Encoder_New(230dd22efc6416a5).(WINPR_ASN1_DERcxx . . $ WINPR_ASN1_DER.);
47 if (!enc)
48 return FALSEcxx . . $ `winpr/include/winpr/wtypes.h:122:9`!;
49
50 /* initialContextToken [APPLICATION 0] */
51 if (!WinPrAsn1EncAppContainercxx . . $ WinPrAsn1EncAppContainer(44e8d7d1a70530a5).(enc, 0))
52 goto cleanup;
53
54 /* thisMech OID */
55 if (!WinPrAsn1EncOIDcxx . . $ WinPrAsn1EncOID(55fe8a0323b9182a).(enc, oid))
56 goto cleanup;
57
58 /* TOK_ID */
59 if (!WinPrAsn1EncRawContentcxx . . $ WinPrAsn1EncRawContent(55fe8a0323b9182a).(enc, &mc))
60 goto cleanup;
61
62 /* innerToken */
63 mc.datacxx . . $ $anonymous_type_41db265f08275ce7_2#data. = (BYTEcxx . . $ BYTE#*)token->datacxx . . $ _krb5_data#data.;
64 mc.lencxx . . $ $anonymous_type_41db265f08275ce7_2#len. = token->lengthcxx . . $ _krb5_data#length.;
65 if (!WinPrAsn1EncRawContentcxx . . $ WinPrAsn1EncRawContent(55fe8a0323b9182a).(enc, &mc))
66 goto cleanup;
67
68 if (!WinPrAsn1EncEndContainercxx . . $ WinPrAsn1EncEndContainer(9cfb7cc50cd2a2e1).(enc))
69 goto cleanup;
70
71 if (!WinPrAsn1EncStreamSizecxx . . $ WinPrAsn1EncStreamSize(7491d667398adca3).(enc, &len) || len > buf->cbBuffercxx . . $ $anonymous_type_13c8ac8e1b4cb2c0_44#cbBuffer.)
72 goto cleanup;
73
74 Stream_StaticInitcxx . . $ Stream_StaticInit(a93e379cdb0b7c14).(&s, buf->pvBuffercxx . . $ $anonymous_type_13c8ac8e1b4cb2c0_44#pvBuffer., len);
75 if (WinPrAsn1EncToStreamcxx . . $ WinPrAsn1EncToStream(eccd197e98b9208).(enc, &s))
76 {
77 buf->cbBuffercxx . . $ $anonymous_type_13c8ac8e1b4cb2c0_44#cbBuffer. = (UINT32cxx . . $ UINT32#)len;
78 ret = TRUEcxx . . $ `winpr/include/winpr/wtypes.h:126:9`!;
79 }
80
81 cleanup:
82 WinPrAsn1Encoder_Freecxx . . $ WinPrAsn1Encoder_Free(b1493289c6e4e358).(&enc);
83 return ret;
84 }
85
86 BOOLcxx . . $ BOOL# sspi_gss_unwrap_tokencxx . . $ sspi_gss_unwrap_token(21f4760d91683802).(const SecBuffercxx . . $ SecBuffer#* buf, WinPrAsn1_OIDcxx . . $ WinPrAsn1_OID#* oid, uint16_tcxx . . $ uint16_t#* tok_id,
87 sspi_gss_datacxx . . $ sspi_gss_data#* token)
88 {
89 WinPrAsn1Decodercxx . . $ WinPrAsn1Decoder# dec = WinPrAsn1Decoder_initcxx . . $ WinPrAsn1Decoder_init(9f2b2b04a0169e89).();
90 WinPrAsn1Decodercxx . . $ WinPrAsn1Decoder# dec2 = WinPrAsn1Decoder_initcxx . . $ WinPrAsn1Decoder_init(9f2b2b04a0169e89).();
91 WinPrAsn1_tagIdcxx . . $ WinPrAsn1_tagId# tag = 0;
92 wStreamcxx . . $ wStream# sbuffer = WINPR_C_ARRAY_INITcxx . . $ `winpr/include/winpr/platform.h:87:9`!;
93 wStreamcxx . . $ wStream#* s = nullptrcxx . . $ `winpr/include/winpr/platform.h:88:9`!;
94
95 WINPR_ASSERTcxx . . $ `winpr/include/winpr/assert-api.h:76:9`!(buf);
96 WINPR_ASSERTcxx . . $ `winpr/include/winpr/assert-api.h:76:9`!(oid);
97 WINPR_ASSERTcxx . . $ `winpr/include/winpr/assert-api.h:76:9`!(token);
98
99 WinPrAsn1Decoder_InitMemcxx . . $ WinPrAsn1Decoder_InitMem(87018fb168845641).(&dec, WINPR_ASN1_DERcxx . . $ WINPR_ASN1_DER., buf->pvBuffercxx . . $ $anonymous_type_13c8ac8e1b4cb2c0_44#pvBuffer., buf->cbBuffercxx . . $ $anonymous_type_13c8ac8e1b4cb2c0_44#cbBuffer.);
100
101 if (!WinPrAsn1DecReadAppcxx . . $ WinPrAsn1DecReadApp(6e392b4d237c4dfd).(&dec, &tag, &dec2) || tag != 0)
102 return FALSEcxx . . $ `winpr/include/winpr/wtypes.h:122:9`!;
103
104 if (!WinPrAsn1DecReadOIDcxx . . $ WinPrAsn1DecReadOID(21289d36764807d6).(&dec2, oid, FALSEcxx . . $ `winpr/include/winpr/wtypes.h:122:9`!))
105 return FALSEcxx . . $ `winpr/include/winpr/wtypes.h:122:9`!;
106
107 sbuffer = WinPrAsn1DecGetStreamcxx . . $ WinPrAsn1DecGetStream(55d1c207c5d12112).(&dec2);
108 s = &sbuffer;
109
110 if (Stream_Lengthcxx . . $ Stream_Length(ebc7f695a8644dc0).(s) < 2)
111 return FALSEcxx . . $ `winpr/include/winpr/wtypes.h:122:9`!;
112
113 if (tok_id)
114 Stream_Read_UINT16_BEcxx . . $ `winpr/include/winpr/stream.h:671:9`!(s, *tok_id);
115
116 token->datacxx . . $ _krb5_data#data. = Stream_Pointercxx . . $ Stream_Pointer(542a419ec0593470).(s);
117 token->lengthcxx . . $ _krb5_data#length. = (UINTcxx . . $ UINT#)Stream_GetRemainingLengthcxx . . $ Stream_GetRemainingLength(ebc7f695a8644dc0).(s);
118
119 return TRUEcxx . . $ `winpr/include/winpr/wtypes.h:126:9`!;
120 }