コード例 #1
0
static int ocsp_certid_print(BIO *bp, OCSP_CERTID* a, int indent)
        {
	BIO_printf(bp, "%*sCertificate ID:\n", indent, "");
	indent += 2;
	BIO_printf(bp, "%*sHash Algorithm: ", indent, "");
	i2a_ASN1_OBJECT(bp, a->hashAlgorithm->algorithm);
	BIO_printf(bp, "\n%*sIssuer Name Hash: ", indent, "");
	i2a_ASN1_STRING(bp, a->issuerNameHash, V_ASN1_OCTET_STRING);
	BIO_printf(bp, "\n%*sIssuer Key Hash: ", indent, "");
	i2a_ASN1_STRING(bp, a->issuerKeyHash, V_ASN1_OCTET_STRING);
	BIO_printf(bp, "\n%*sSerial Number: ", indent, "");
	i2a_ASN1_INTEGER(bp, a->serialNumber);
	BIO_printf(bp, "\n");
	return 1;
	}
コード例 #2
0
/**
 * functionName : asn1_octet_string_print
 * @Param : ASN1_OCTET_STRING * octet
 * Brief  : 
 *		print data with ASN1_OCTET_STRING type
 * return :  null
 */
void asn1_octet_string_print(ASN1_OCTET_STRING *octet){
	BIO *out = BIO_new(BIO_s_file());
	BIO_set_fp(out,stdout,BIO_NOCLOSE);	
	i2a_ASN1_STRING(out,octet,1);
	BIO_free(out);
	printf("\n");
}
コード例 #3
0
ファイル: v3_ocsp.c プロジェクト: CoryXie/BarrelfishOS
static int i2r_ocsp_nonce(const X509V3_EXT_METHOD *method, void *nonce,
			  BIO *out, int indent)
{
	if(BIO_printf(out, "%*s", indent, "") <= 0) return 0;
	if(i2a_ASN1_STRING(out, nonce, V_ASN1_OCTET_STRING) <= 0) return 0;
	return 1;
}
コード例 #4
0
/**
 * functionName : signer_info_print
 * @Param : PKCS7_SIGNER_INFO *info [ signer information ]
 * Brief  : 
 *		print signer info with PKCS7_SIGNER_INFO type
 * return :  null
 */
void signer_info_print(PKCS7_SIGNER_INFO*info){
	long version,serail;

	printf("****************************************************************\n");
	printf("signer_info_print...\n");
	version =  ASN1_INTEGER_get(info->version);			
	printf("version:%d\n",version);

//	printf("ISSUER AND SERIAL\n");
	serail = ASN1_INTEGER_get(info->issuer_and_serial->serial); 
	printf("serial:%ld\n",serail);
	printf("ISSUER INFO:");
	BIO *out = BIO_new(BIO_s_file());
	BIO_set_fp(out,stdout,BIO_NOCLOSE);
	X509_NAME_print(out,info->issuer_and_serial->issuer,0);
	BIO_free(out);
	printf("\n");

	printf("DIGEST_ALGORITHM:");
	BIO *b_alg = BIO_new(BIO_s_file());
	X509_ALGOR_print(b_alg,info->digest_alg);
	BIO_free(b_alg);

	printf("DIGEST_ENCRYPT_ALGORITHM:");
	BIO *b_enc_alg = BIO_new(BIO_s_file());
	X509_ALGOR_print(b_enc_alg,info->digest_enc_alg);
	BIO_free(b_enc_alg);

	printf("ENCRYPT DIGEST:");
	BIO *b_enc_dig = BIO_new(BIO_s_file());
	BIO_set_fp(b_enc_dig,stdout,BIO_NOCLOSE);	
	i2a_ASN1_STRING(b_enc_dig,info->enc_digest,1);
	BIO_free(b_enc_dig);
	printf("\n");

	printf("signer_info_print... END\n");	
	printf("****************************************************************\n");
}
コード例 #5
0
int OCSP_RESPONSE_print(BIO *bp, OCSP_RESPONSE* o, unsigned long flags)
        {
	int i, ret = 0;
	long l;
	OCSP_CERTID *cid = NULL;
	OCSP_BASICRESP *br = NULL;
	OCSP_RESPID *rid = NULL;
	OCSP_RESPDATA  *rd = NULL;
	OCSP_CERTSTATUS *cst = NULL;
	OCSP_REVOKEDINFO *rev = NULL;
	OCSP_SINGLERESP *single = NULL;
	OCSP_RESPBYTES *rb = o->responseBytes;

	if (BIO_puts(bp,"OCSP Response Data:\n") <= 0) goto err;
	l=ASN1_ENUMERATED_get(o->responseStatus);
	if (BIO_printf(bp,"    OCSP Response Status: %s (0x%lx)\n",
		       OCSP_response_status_str(l), l) <= 0) goto err;
	if (rb == NULL) return 1;
        if (BIO_puts(bp,"    Response Type: ") <= 0)
	        goto err;
	if(i2a_ASN1_OBJECT(bp, rb->responseType) <= 0)
	        goto err;
	if (OBJ_obj2nid(rb->responseType) != NID_id_pkix_OCSP_basic) 
	        {
		BIO_puts(bp," (unknown response type)\n");
		return 1;
		}

	i = ASN1_STRING_length(rb->response);
	if (!(br = OCSP_response_get1_basic(o))) goto err;
	rd = br->tbsResponseData;
	l=ASN1_INTEGER_get(rd->version);
	if (BIO_printf(bp,"\n    Version: %lu (0x%lx)\n",
		       l+1,l) <= 0) goto err;
	if (BIO_puts(bp,"    Responder Id: ") <= 0) goto err;

	rid =  rd->responderId;
	switch (rid->type)
		{
		case V_OCSP_RESPID_NAME:
		        X509_NAME_print_ex(bp, rid->value.byName, 0, XN_FLAG_ONELINE);
		        break;
		case V_OCSP_RESPID_KEY:
		        i2a_ASN1_STRING(bp, rid->value.byKey, V_ASN1_OCTET_STRING);
		        break;
		}

	if (BIO_printf(bp,"\n    Produced At: ")<=0) goto err;
	if (!ASN1_GENERALIZEDTIME_print(bp, rd->producedAt)) goto err;
	if (BIO_printf(bp,"\n    Responses:\n") <= 0) goto err;
	for (i = 0; i < sk_OCSP_SINGLERESP_num(rd->responses); i++)
	        {
		if (! sk_OCSP_SINGLERESP_value(rd->responses, i)) continue;
		single = sk_OCSP_SINGLERESP_value(rd->responses, i);
		cid = single->certId;
		if(ocsp_certid_print(bp, cid, 4) <= 0) goto err;
		cst = single->certStatus;
		if (BIO_printf(bp,"    Cert Status: %s",
			       OCSP_cert_status_str(cst->type)) <= 0)
		        goto err;
		if (cst->type == V_OCSP_CERTSTATUS_REVOKED)
		        {
		        rev = cst->value.revoked;
			if (BIO_printf(bp, "\n    Revocation Time: ") <= 0) 
			        goto err;
			if (!ASN1_GENERALIZEDTIME_print(bp, 
							rev->revocationTime)) 
				goto err;
			if (rev->revocationReason) 
			        {
				l=ASN1_ENUMERATED_get(rev->revocationReason);
				if (BIO_printf(bp, 
					 "\n    Revocation Reason: %s (0x%lx)",
					       OCSP_crl_reason_str(l), l) <= 0)
				        goto err;
				}
			}
		if (BIO_printf(bp,"\n    This Update: ") <= 0) goto err;
		if (!ASN1_GENERALIZEDTIME_print(bp, single->thisUpdate)) 
			goto err;
		if (single->nextUpdate)
		        {
			if (BIO_printf(bp,"\n    Next Update: ") <= 0)goto err;
			if (!ASN1_GENERALIZEDTIME_print(bp,single->nextUpdate))
				goto err;
			}
		if (BIO_write(bp,"\n",1) <= 0) goto err;
		if (!X509V3_extensions_print(bp,
					"Response Single Extensions",
					single->singleExtensions, flags, 8))
							goto err;
		if (BIO_write(bp,"\n",1) <= 0) goto err;
		}
	if (!X509V3_extensions_print(bp, "Response Extensions",
					rd->responseExtensions, flags, 4))
							goto err;
	if(X509_signature_print(bp, br->signatureAlgorithm, br->signature) <= 0)
							goto err;

	for (i=0; i<sk_X509_num(br->certs); i++)
		{
		X509_print(bp, sk_X509_value(br->certs,i));
		PEM_write_bio_X509(bp,sk_X509_value(br->certs,i));
		}

	ret = 1;
err:
	OCSP_BASICRESP_free(br);
	return ret;
	}