github.com/zmap/zlint@v1.1.0/lints/lint_qcstatem_qcsscd_valid.go (about) 1 /* 2 * ZLint Copyright 2017 Regents of the University of Michigan 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); you may not 5 * use this file except in compliance with the License. You may obtain a copy 6 * of the License at http://www.apache.org/licenses/LICENSE-2.0 7 * 8 * Unless required by applicable law or agreed to in writing, software 9 * distributed under the License is distributed on an "AS IS" BASIS, 10 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 11 * implied. See the License for the specific language governing 12 * permissions and limitations under the License. 13 */ 14 15 package lints 16 17 import ( 18 "encoding/asn1" 19 "github.com/zmap/zcrypto/x509" 20 "github.com/zmap/zlint/util" 21 ) 22 23 type qcStatemQcSscdValid struct{} 24 25 func (this *qcStatemQcSscdValid) getStatementOid() *asn1.ObjectIdentifier { 26 return &util.IdEtsiQcsQcSSCD 27 } 28 29 func (l *qcStatemQcSscdValid) Initialize() error { 30 return nil 31 } 32 33 func (l *qcStatemQcSscdValid) CheckApplies(c *x509.Certificate) bool { 34 if !util.IsExtInCert(c, util.QcStateOid) { 35 return false 36 } 37 if util.ParseQcStatem(util.GetExtFromCert(c, util.QcStateOid).Value, *l.getStatementOid()).IsPresent() { 38 return true 39 } 40 return false 41 } 42 43 func (l *qcStatemQcSscdValid) Execute(c *x509.Certificate) *LintResult { 44 45 errString := "" 46 ext := util.GetExtFromCert(c, util.QcStateOid) 47 s := util.ParseQcStatem(ext.Value, *l.getStatementOid()) 48 errString += s.GetErrorInfo() 49 50 if len(errString) == 0 { 51 return &LintResult{Status: Pass} 52 } else { 53 return &LintResult{Status: Error, Details: errString} 54 } 55 } 56 57 func init() { 58 RegisterLint(&Lint{ 59 Name: "e_qcstatem_qcsscd_valid", 60 Description: "Checks that a QC Statement of the type id-etsi-qcs-QcSSCD has the correct form", 61 Citation: "ETSI EN 319 412 - 5 V2.2.1 (2017 - 11) / Section 4.2.2", 62 Source: EtsiEsi, 63 EffectiveDate: util.EtsiEn319_412_5_V2_2_1_Date, 64 Lint: &qcStatemQcSscdValid{}, 65 }) 66 }