1221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstrom/* crypto/objects/obj_xref.c */ 2221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstrom/* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL 3221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstrom * project 2006. 4221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstrom */ 5221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstrom/* ==================================================================== 6221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstrom * Copyright (c) 2006 The OpenSSL Project. All rights reserved. 7221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstrom * 8221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstrom * Redistribution and use in source and binary forms, with or without 9221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstrom * modification, are permitted provided that the following conditions 10221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstrom * are met: 11221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstrom * 12221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstrom * 1. Redistributions of source code must retain the above copyright 13221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstrom * notice, this list of conditions and the following disclaimer. 14221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstrom * 15221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstrom * 2. Redistributions in binary form must reproduce the above copyright 16221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstrom * notice, this list of conditions and the following disclaimer in 17221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstrom * the documentation and/or other materials provided with the 18221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstrom * distribution. 19221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstrom * 20221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstrom * 3. All advertising materials mentioning features or use of this 21221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstrom * software must display the following acknowledgment: 22221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstrom * "This product includes software developed by the OpenSSL Project 23221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstrom * for use in the OpenSSL Toolkit. (http://www.OpenSSL.org/)" 24221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstrom * 25221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstrom * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to 26221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstrom * endorse or promote products derived from this software without 27221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstrom * prior written permission. For written permission, please contact 28221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstrom * licensing@OpenSSL.org. 29221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstrom * 30221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstrom * 5. Products derived from this software may not be called "OpenSSL" 31221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstrom * nor may "OpenSSL" appear in their names without prior written 32221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstrom * permission of the OpenSSL Project. 33221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstrom * 34221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstrom * 6. Redistributions of any form whatsoever must retain the following 35221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstrom * acknowledgment: 36221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstrom * "This product includes software developed by the OpenSSL Project 37221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstrom * for use in the OpenSSL Toolkit (http://www.OpenSSL.org/)" 38221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstrom * 39221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstrom * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY 40221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstrom * EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 41221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstrom * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 42221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstrom * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR 43221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstrom * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 44221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstrom * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 45221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstrom * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 46221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstrom * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 47221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstrom * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, 48221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstrom * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 49221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstrom * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED 50221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstrom * OF THE POSSIBILITY OF SUCH DAMAGE. 51221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstrom * ==================================================================== 52221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstrom * 53221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstrom * This product includes cryptographic software written by Eric Young 54221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstrom * (eay@cryptsoft.com). This product includes software written by Tim 55221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstrom * Hudson (tjh@cryptsoft.com). 56221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstrom * 57221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstrom */ 58221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstrom 59221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstrom#include <openssl/objects.h> 60221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstrom#include "obj_xref.h" 61221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstrom 62221304ee937bc0910948a8be1320cb8cc4eb6d36Brian CarlstromDECLARE_STACK_OF(nid_triple) 63221304ee937bc0910948a8be1320cb8cc4eb6d36Brian CarlstromSTACK_OF(nid_triple) *sig_app, *sigx_app; 64221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstrom 65221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstromstatic int sig_cmp(const nid_triple *a, const nid_triple *b) 66221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstrom { 67221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstrom return a->sign_id - b->sign_id; 68221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstrom } 69221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstrom 70221304ee937bc0910948a8be1320cb8cc4eb6d36Brian CarlstromDECLARE_OBJ_BSEARCH_CMP_FN(nid_triple, nid_triple, sig); 71221304ee937bc0910948a8be1320cb8cc4eb6d36Brian CarlstromIMPLEMENT_OBJ_BSEARCH_CMP_FN(nid_triple, nid_triple, sig); 72221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstrom 73221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstromstatic int sig_sk_cmp(const nid_triple * const *a, const nid_triple * const *b) 74221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstrom { 75221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstrom return (*a)->sign_id - (*b)->sign_id; 76221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstrom } 77221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstrom 78221304ee937bc0910948a8be1320cb8cc4eb6d36Brian CarlstromDECLARE_OBJ_BSEARCH_CMP_FN(const nid_triple *, const nid_triple *, sigx); 79221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstrom 80221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstromstatic int sigx_cmp(const nid_triple * const *a, const nid_triple * const *b) 81221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstrom { 82221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstrom int ret; 83221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstrom ret = (*a)->hash_id - (*b)->hash_id; 84221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstrom if (ret) 85221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstrom return ret; 86221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstrom return (*a)->pkey_id - (*b)->pkey_id; 87221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstrom } 88221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstrom 89221304ee937bc0910948a8be1320cb8cc4eb6d36Brian CarlstromIMPLEMENT_OBJ_BSEARCH_CMP_FN(const nid_triple *, const nid_triple *, sigx); 90221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstrom 91221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstromint OBJ_find_sigid_algs(int signid, int *pdig_nid, int *ppkey_nid) 92221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstrom { 93221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstrom nid_triple tmp; 94221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstrom const nid_triple *rv = NULL; 95221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstrom tmp.sign_id = signid; 96221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstrom 97221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstrom if (sig_app) 98221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstrom { 99221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstrom int idx = sk_nid_triple_find(sig_app, &tmp); 100221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstrom if (idx >= 0) 101221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstrom rv = sk_nid_triple_value(sig_app, idx); 102221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstrom } 103221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstrom 104221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstrom#ifndef OBJ_XREF_TEST2 105221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstrom if (rv == NULL) 106221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstrom { 107221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstrom rv = OBJ_bsearch_sig(&tmp, sigoid_srt, 108221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstrom sizeof(sigoid_srt) / sizeof(nid_triple)); 109221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstrom } 110221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstrom#endif 111221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstrom if (rv == NULL) 112221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstrom return 0; 113392aa7cc7d2b122614c5393c3e357da07fd07af3Brian Carlstrom if (pdig_nid) 114392aa7cc7d2b122614c5393c3e357da07fd07af3Brian Carlstrom *pdig_nid = rv->hash_id; 115392aa7cc7d2b122614c5393c3e357da07fd07af3Brian Carlstrom if (ppkey_nid) 116392aa7cc7d2b122614c5393c3e357da07fd07af3Brian Carlstrom *ppkey_nid = rv->pkey_id; 117221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstrom return 1; 118221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstrom } 119221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstrom 120221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstromint OBJ_find_sigid_by_algs(int *psignid, int dig_nid, int pkey_nid) 121221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstrom { 122221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstrom nid_triple tmp; 123221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstrom const nid_triple *t=&tmp; 124221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstrom const nid_triple **rv = NULL; 125221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstrom 126221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstrom tmp.hash_id = dig_nid; 127221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstrom tmp.pkey_id = pkey_nid; 128221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstrom 129221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstrom if (sigx_app) 130221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstrom { 131221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstrom int idx = sk_nid_triple_find(sigx_app, &tmp); 132221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstrom if (idx >= 0) 133221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstrom { 134221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstrom t = sk_nid_triple_value(sigx_app, idx); 135221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstrom rv = &t; 136221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstrom } 137221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstrom } 138221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstrom 139221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstrom#ifndef OBJ_XREF_TEST2 140221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstrom if (rv == NULL) 141221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstrom { 142221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstrom rv = OBJ_bsearch_sigx(&t, sigoid_srt_xref, 143221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstrom sizeof(sigoid_srt_xref) / sizeof(nid_triple *) 144221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstrom ); 145221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstrom } 146221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstrom#endif 147221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstrom if (rv == NULL) 148221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstrom return 0; 149392aa7cc7d2b122614c5393c3e357da07fd07af3Brian Carlstrom if (psignid) 150392aa7cc7d2b122614c5393c3e357da07fd07af3Brian Carlstrom *psignid = (*rv)->sign_id; 151221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstrom return 1; 152221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstrom } 153221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstrom 154221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstromint OBJ_add_sigid(int signid, int dig_id, int pkey_id) 155221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstrom { 156221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstrom nid_triple *ntr; 157221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstrom if (!sig_app) 158221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstrom sig_app = sk_nid_triple_new(sig_sk_cmp); 159221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstrom if (!sig_app) 160221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstrom return 0; 161221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstrom if (!sigx_app) 162221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstrom sigx_app = sk_nid_triple_new(sigx_cmp); 163221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstrom if (!sigx_app) 164221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstrom return 0; 165221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstrom ntr = OPENSSL_malloc(sizeof(int) * 3); 166221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstrom if (!ntr) 167221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstrom return 0; 168221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstrom ntr->sign_id = signid; 169221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstrom ntr->hash_id = dig_id; 170221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstrom ntr->pkey_id = pkey_id; 171221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstrom 172221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstrom if (!sk_nid_triple_push(sig_app, ntr)) 173221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstrom { 174221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstrom OPENSSL_free(ntr); 175221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstrom return 0; 176221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstrom } 177221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstrom 178221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstrom if (!sk_nid_triple_push(sigx_app, ntr)) 179221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstrom return 0; 180221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstrom 181221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstrom sk_nid_triple_sort(sig_app); 182221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstrom sk_nid_triple_sort(sigx_app); 183221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstrom 184221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstrom return 1; 185221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstrom } 186221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstrom 187221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstromstatic void sid_free(nid_triple *tt) 188221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstrom { 189221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstrom OPENSSL_free(tt); 190221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstrom } 191221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstrom 192221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstromvoid OBJ_sigid_free(void) 193221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstrom { 194221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstrom if (sig_app) 195221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstrom { 196221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstrom sk_nid_triple_pop_free(sig_app, sid_free); 197221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstrom sig_app = NULL; 198221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstrom } 199221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstrom if (sigx_app) 200221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstrom { 201221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstrom sk_nid_triple_free(sigx_app); 202221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstrom sigx_app = NULL; 203221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstrom } 204221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstrom } 205221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstrom 206221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstrom#ifdef OBJ_XREF_TEST 207221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstrom 208221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstrommain() 209221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstrom { 210221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstrom int n1, n2, n3; 211221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstrom 212221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstrom int i, rv; 213221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstrom#ifdef OBJ_XREF_TEST2 214221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstrom for (i = 0; i < sizeof(sigoid_srt) / sizeof(nid_triple); i++) 215221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstrom { 216221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstrom OBJ_add_sigid(sigoid_srt[i][0], sigoid_srt[i][1], 217221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstrom sigoid_srt[i][2]); 218221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstrom } 219221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstrom#endif 220221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstrom 221221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstrom for (i = 0; i < sizeof(sigoid_srt) / sizeof(nid_triple); i++) 222221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstrom { 223221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstrom n1 = sigoid_srt[i][0]; 224221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstrom rv = OBJ_find_sigid_algs(n1, &n2, &n3); 225221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstrom printf("Forward: %d, %s %s %s\n", rv, 226221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstrom OBJ_nid2ln(n1), OBJ_nid2ln(n2), OBJ_nid2ln(n3)); 227221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstrom n1=0; 228221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstrom rv = OBJ_find_sigid_by_algs(&n1, n2, n3); 229221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstrom printf("Reverse: %d, %s %s %s\n", rv, 230221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstrom OBJ_nid2ln(n1), OBJ_nid2ln(n2), OBJ_nid2ln(n3)); 231221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstrom } 232221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstrom } 233221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstrom 234221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstrom#endif 235