|
@@ -483,6 +483,7 @@ decode_negTokenInit(unsigned char *security_blob, int length,
|
|
|
|
|
|
asn1_open(&ctx, security_blob, length);
|
|
|
|
|
|
+ /* GSSAPI header */
|
|
|
if (asn1_header_decode(&ctx, &end, &cls, &con, &tag) == 0) {
|
|
|
cFYI(1, ("Error decoding negTokenInit header"));
|
|
|
return 0;
|
|
@@ -490,154 +491,142 @@ decode_negTokenInit(unsigned char *security_blob, int length,
|
|
|
|| (tag != ASN1_EOC)) {
|
|
|
cFYI(1, ("cls = %d con = %d tag = %d", cls, con, tag));
|
|
|
return 0;
|
|
|
- } else {
|
|
|
- /* remember to free obj->oid */
|
|
|
- rc = asn1_header_decode(&ctx, &end, &cls, &con, &tag);
|
|
|
- if (rc) {
|
|
|
- if ((tag == ASN1_OJI) && (con == ASN1_PRI) &&
|
|
|
- (cls == ASN1_UNI)) {
|
|
|
- rc = asn1_oid_decode(&ctx, end, &oid, &oidlen);
|
|
|
- if (rc) {
|
|
|
- rc = compare_oid(oid, oidlen,
|
|
|
- SPNEGO_OID,
|
|
|
- SPNEGO_OID_LEN);
|
|
|
- kfree(oid);
|
|
|
- }
|
|
|
- } else
|
|
|
- rc = 0;
|
|
|
- }
|
|
|
+ }
|
|
|
|
|
|
- if (!rc) {
|
|
|
- cFYI(1, ("Error decoding negTokenInit header"));
|
|
|
- return 0;
|
|
|
- }
|
|
|
+ /* Check for SPNEGO OID -- remember to free obj->oid */
|
|
|
+ rc = asn1_header_decode(&ctx, &end, &cls, &con, &tag);
|
|
|
+ if (rc) {
|
|
|
+ if ((tag == ASN1_OJI) && (con == ASN1_PRI) &&
|
|
|
+ (cls == ASN1_UNI)) {
|
|
|
+ rc = asn1_oid_decode(&ctx, end, &oid, &oidlen);
|
|
|
+ if (rc) {
|
|
|
+ rc = compare_oid(oid, oidlen, SPNEGO_OID,
|
|
|
+ SPNEGO_OID_LEN);
|
|
|
+ kfree(oid);
|
|
|
+ }
|
|
|
+ } else
|
|
|
+ rc = 0;
|
|
|
+ }
|
|
|
|
|
|
- if (asn1_header_decode(&ctx, &end, &cls, &con, &tag) == 0) {
|
|
|
- cFYI(1, ("Error decoding negTokenInit"));
|
|
|
- return 0;
|
|
|
- } else if ((cls != ASN1_CTX) || (con != ASN1_CON)
|
|
|
- || (tag != ASN1_EOC)) {
|
|
|
- cFYI(1,
|
|
|
- ("cls = %d con = %d tag = %d end = %p (%d) exit 0",
|
|
|
- cls, con, tag, end, *end));
|
|
|
- return 0;
|
|
|
- }
|
|
|
+ /* SPNEGO OID not present or garbled -- bail out */
|
|
|
+ if (!rc) {
|
|
|
+ cFYI(1, ("Error decoding negTokenInit header"));
|
|
|
+ return 0;
|
|
|
+ }
|
|
|
|
|
|
- if (asn1_header_decode(&ctx, &end, &cls, &con, &tag) == 0) {
|
|
|
- cFYI(1, ("Error decoding negTokenInit"));
|
|
|
- return 0;
|
|
|
- } else if ((cls != ASN1_UNI) || (con != ASN1_CON)
|
|
|
- || (tag != ASN1_SEQ)) {
|
|
|
- cFYI(1,
|
|
|
- ("cls = %d con = %d tag = %d end = %p (%d) exit 1",
|
|
|
- cls, con, tag, end, *end));
|
|
|
- return 0;
|
|
|
- }
|
|
|
+ if (asn1_header_decode(&ctx, &end, &cls, &con, &tag) == 0) {
|
|
|
+ cFYI(1, ("Error decoding negTokenInit"));
|
|
|
+ return 0;
|
|
|
+ } else if ((cls != ASN1_CTX) || (con != ASN1_CON)
|
|
|
+ || (tag != ASN1_EOC)) {
|
|
|
+ cFYI(1,
|
|
|
+ ("cls = %d con = %d tag = %d end = %p (%d) exit 0",
|
|
|
+ cls, con, tag, end, *end));
|
|
|
+ return 0;
|
|
|
+ }
|
|
|
|
|
|
- if (asn1_header_decode(&ctx, &end, &cls, &con, &tag) == 0) {
|
|
|
- cFYI(1, ("Error decoding 2nd part of negTokenInit"));
|
|
|
- return 0;
|
|
|
- } else if ((cls != ASN1_CTX) || (con != ASN1_CON)
|
|
|
- || (tag != ASN1_EOC)) {
|
|
|
- cFYI(1,
|
|
|
- ("cls = %d con = %d tag = %d end = %p (%d) exit 0",
|
|
|
- cls, con, tag, end, *end));
|
|
|
- return 0;
|
|
|
- }
|
|
|
+ if (asn1_header_decode(&ctx, &end, &cls, &con, &tag) == 0) {
|
|
|
+ cFYI(1, ("Error decoding negTokenInit"));
|
|
|
+ return 0;
|
|
|
+ } else if ((cls != ASN1_UNI) || (con != ASN1_CON)
|
|
|
+ || (tag != ASN1_SEQ)) {
|
|
|
+ cFYI(1,
|
|
|
+ ("cls = %d con = %d tag = %d end = %p (%d) exit 1",
|
|
|
+ cls, con, tag, end, *end));
|
|
|
+ return 0;
|
|
|
+ }
|
|
|
|
|
|
- if (asn1_header_decode
|
|
|
- (&ctx, &sequence_end, &cls, &con, &tag) == 0) {
|
|
|
- cFYI(1, ("Error decoding 2nd part of negTokenInit"));
|
|
|
- return 0;
|
|
|
- } else if ((cls != ASN1_UNI) || (con != ASN1_CON)
|
|
|
- || (tag != ASN1_SEQ)) {
|
|
|
- cFYI(1,
|
|
|
- ("cls = %d con = %d tag = %d end = %p (%d) exit 1",
|
|
|
- cls, con, tag, end, *end));
|
|
|
- return 0;
|
|
|
- }
|
|
|
+ if (asn1_header_decode(&ctx, &end, &cls, &con, &tag) == 0) {
|
|
|
+ cFYI(1, ("Error decoding 2nd part of negTokenInit"));
|
|
|
+ return 0;
|
|
|
+ } else if ((cls != ASN1_CTX) || (con != ASN1_CON)
|
|
|
+ || (tag != ASN1_EOC)) {
|
|
|
+ cFYI(1,
|
|
|
+ ("cls = %d con = %d tag = %d end = %p (%d) exit 0",
|
|
|
+ cls, con, tag, end, *end));
|
|
|
+ return 0;
|
|
|
+ }
|
|
|
|
|
|
- while (!asn1_eoc_decode(&ctx, sequence_end)) {
|
|
|
- rc = asn1_header_decode(&ctx, &end, &cls, &con, &tag);
|
|
|
- if (!rc) {
|
|
|
- cFYI(1,
|
|
|
- ("Error decoding negTokenInit hdr exit2"));
|
|
|
- return 0;
|
|
|
- }
|
|
|
- if ((tag == ASN1_OJI) && (con == ASN1_PRI)) {
|
|
|
- if (asn1_oid_decode(&ctx, end, &oid, &oidlen)) {
|
|
|
-
|
|
|
- cFYI(1,
|
|
|
- ("OID len = %d oid = 0x%lx 0x%lx "
|
|
|
- "0x%lx 0x%lx",
|
|
|
- oidlen, *oid, *(oid + 1),
|
|
|
- *(oid + 2), *(oid + 3)));
|
|
|
-
|
|
|
- if (compare_oid(oid, oidlen,
|
|
|
- MSKRB5_OID,
|
|
|
- MSKRB5_OID_LEN))
|
|
|
- use_kerberos = true;
|
|
|
- else if (compare_oid(oid, oidlen,
|
|
|
- KRB5_OID,
|
|
|
- KRB5_OID_LEN))
|
|
|
- use_kerberos = true;
|
|
|
- else if (compare_oid(oid, oidlen,
|
|
|
- NTLMSSP_OID,
|
|
|
- NTLMSSP_OID_LEN))
|
|
|
- use_ntlmssp = true;
|
|
|
-
|
|
|
- kfree(oid);
|
|
|
- }
|
|
|
- } else {
|
|
|
- cFYI(1, ("Should be an oid what is going on?"));
|
|
|
- }
|
|
|
- }
|
|
|
+ if (asn1_header_decode
|
|
|
+ (&ctx, &sequence_end, &cls, &con, &tag) == 0) {
|
|
|
+ cFYI(1, ("Error decoding 2nd part of negTokenInit"));
|
|
|
+ return 0;
|
|
|
+ } else if ((cls != ASN1_UNI) || (con != ASN1_CON)
|
|
|
+ || (tag != ASN1_SEQ)) {
|
|
|
+ cFYI(1,
|
|
|
+ ("cls = %d con = %d tag = %d end = %p (%d) exit 1",
|
|
|
+ cls, con, tag, end, *end));
|
|
|
+ return 0;
|
|
|
+ }
|
|
|
|
|
|
- if (asn1_header_decode(&ctx, &end, &cls, &con, &tag) == 0) {
|
|
|
- cFYI(1,
|
|
|
- ("Error decoding last part negTokenInit exit3"));
|
|
|
- return 0;
|
|
|
- } else if ((cls != ASN1_CTX) || (con != ASN1_CON)) {
|
|
|
- /* tag = 3 indicating mechListMIC */
|
|
|
+ while (!asn1_eoc_decode(&ctx, sequence_end)) {
|
|
|
+ rc = asn1_header_decode(&ctx, &end, &cls, &con, &tag);
|
|
|
+ if (!rc) {
|
|
|
cFYI(1,
|
|
|
- ("Exit 4 cls = %d con = %d tag = %d end = %p (%d)",
|
|
|
- cls, con, tag, end, *end));
|
|
|
+ ("Error decoding negTokenInit hdr exit2"));
|
|
|
return 0;
|
|
|
}
|
|
|
- if (asn1_header_decode(&ctx, &end, &cls, &con, &tag) == 0) {
|
|
|
- cFYI(1,
|
|
|
- ("Error decoding last part negTokenInit exit5"));
|
|
|
- return 0;
|
|
|
- } else if ((cls != ASN1_UNI) || (con != ASN1_CON)
|
|
|
- || (tag != ASN1_SEQ)) {
|
|
|
- cFYI(1, ("cls = %d con = %d tag = %d end = %p (%d)",
|
|
|
- cls, con, tag, end, *end));
|
|
|
+ if ((tag == ASN1_OJI) && (con == ASN1_PRI)) {
|
|
|
+ if (asn1_oid_decode(&ctx, end, &oid, &oidlen)) {
|
|
|
+
|
|
|
+ cFYI(1, ("OID len = %d oid = 0x%lx 0x%lx "
|
|
|
+ "0x%lx 0x%lx", oidlen, *oid,
|
|
|
+ *(oid + 1), *(oid + 2), *(oid + 3)));
|
|
|
+
|
|
|
+ if (compare_oid(oid, oidlen, MSKRB5_OID,
|
|
|
+ MSKRB5_OID_LEN))
|
|
|
+ use_kerberos = true;
|
|
|
+ else if (compare_oid(oid, oidlen, KRB5_OID,
|
|
|
+ KRB5_OID_LEN))
|
|
|
+ use_kerberos = true;
|
|
|
+ else if (compare_oid(oid, oidlen, NTLMSSP_OID,
|
|
|
+ NTLMSSP_OID_LEN))
|
|
|
+ use_ntlmssp = true;
|
|
|
+
|
|
|
+ kfree(oid);
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ cFYI(1, ("Should be an oid what is going on?"));
|
|
|
}
|
|
|
+ }
|
|
|
|
|
|
- if (asn1_header_decode(&ctx, &end, &cls, &con, &tag) == 0) {
|
|
|
- cFYI(1,
|
|
|
- ("Error decoding last part negTokenInit exit 7"));
|
|
|
- return 0;
|
|
|
- } else if ((cls != ASN1_CTX) || (con != ASN1_CON)) {
|
|
|
- cFYI(1,
|
|
|
- ("Exit 8 cls = %d con = %d tag = %d end = %p (%d)",
|
|
|
- cls, con, tag, end, *end));
|
|
|
- return 0;
|
|
|
- }
|
|
|
- if (asn1_header_decode(&ctx, &end, &cls, &con, &tag) == 0) {
|
|
|
- cFYI(1,
|
|
|
- ("Error decoding last part negTokenInit exit9"));
|
|
|
- return 0;
|
|
|
- } else if ((cls != ASN1_UNI) || (con != ASN1_PRI)
|
|
|
- || (tag != ASN1_GENSTR)) {
|
|
|
- cFYI(1,
|
|
|
- ("Exit10 cls = %d con = %d tag = %d end = %p (%d)",
|
|
|
- cls, con, tag, end, *end));
|
|
|
- return 0;
|
|
|
- }
|
|
|
- cFYI(1, ("Need to call asn1_octets_decode() function for %s",
|
|
|
- ctx.pointer)); /* is this UTF-8 or ASCII? */
|
|
|
+ if (asn1_header_decode(&ctx, &end, &cls, &con, &tag) == 0) {
|
|
|
+ cFYI(1, ("Error decoding last part negTokenInit exit3"));
|
|
|
+ return 0;
|
|
|
+ } else if ((cls != ASN1_CTX) || (con != ASN1_CON)) {
|
|
|
+ /* tag = 3 indicating mechListMIC */
|
|
|
+ cFYI(1, ("Exit 4 cls = %d con = %d tag = %d end = %p (%d)",
|
|
|
+ cls, con, tag, end, *end));
|
|
|
+ return 0;
|
|
|
+ }
|
|
|
+ if (asn1_header_decode(&ctx, &end, &cls, &con, &tag) == 0) {
|
|
|
+ cFYI(1, ("Error decoding last part negTokenInit exit5"));
|
|
|
+ return 0;
|
|
|
+ } else if ((cls != ASN1_UNI) || (con != ASN1_CON)
|
|
|
+ || (tag != ASN1_SEQ)) {
|
|
|
+ cFYI(1, ("cls = %d con = %d tag = %d end = %p (%d)",
|
|
|
+ cls, con, tag, end, *end));
|
|
|
+ }
|
|
|
+
|
|
|
+ if (asn1_header_decode(&ctx, &end, &cls, &con, &tag) == 0) {
|
|
|
+ cFYI(1, ("Error decoding last part negTokenInit exit 7"));
|
|
|
+ return 0;
|
|
|
+ } else if ((cls != ASN1_CTX) || (con != ASN1_CON)) {
|
|
|
+ cFYI(1, ("Exit 8 cls = %d con = %d tag = %d end = %p (%d)",
|
|
|
+ cls, con, tag, end, *end));
|
|
|
+ return 0;
|
|
|
+ }
|
|
|
+ if (asn1_header_decode(&ctx, &end, &cls, &con, &tag) == 0) {
|
|
|
+ cFYI(1, ("Error decoding last part negTokenInit exit9"));
|
|
|
+ return 0;
|
|
|
+ } else if ((cls != ASN1_UNI) || (con != ASN1_PRI)
|
|
|
+ || (tag != ASN1_GENSTR)) {
|
|
|
+ cFYI(1, ("Exit10 cls = %d con = %d tag = %d end = %p (%d)",
|
|
|
+ cls, con, tag, end, *end));
|
|
|
+ return 0;
|
|
|
}
|
|
|
+ cFYI(1, ("Need to call asn1_octets_decode() function for %s",
|
|
|
+ ctx.pointer)); /* is this UTF-8 or ASCII? */
|
|
|
|
|
|
if (use_kerberos)
|
|
|
*secType = Kerberos;
|