4 * The contents of this file are subject to the terms of the
5 * Common Development and Distribution License, Version 1.0 only
6 * (the "License"). You may not use this file except in compliance
9 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
10 * or http://www.opensolaris.org/os/licensing.
11 * See the License for the specific language governing permissions
12 * and limitations under the License.
14 * When distributing Covered Code, include this CDDL HEADER in each
15 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
16 * If applicable, add the following below this CDDL HEADER, with the
17 * fields enclosed by brackets "[]" replaced with your own identifying
18 * information: Portions Copyright [yyyy] [name of copyright owner]
23 * Copyright 2003 Sun Microsystems, Inc. All rights reserved.
24 * Use is subject to license terms.
27 #pragma ident "%Z%%M% %I% %E% SMI"
30 * mdb dcmds for selected structures from
31 * usr/src/uts/common/sys/crypto/common.h
34 #include <sys/mdb_modapi.h>
35 #include <sys/modctl.h>
36 #include <sys/types.h>
37 #include <sys/crypto/api.h>
38 #include <sys/crypto/common.h>
39 #include <sys/crypto/spi.h>
40 #include <sys/crypto/impl.h>
41 #include "crypto_cmds.h"
45 crypto_mechanism(uintptr_t addr
, uint_t flags
, int argc
, const mdb_arg_t
*argv
)
47 crypto_mechanism_t mch
;
49 if (!(flags
& DCMD_ADDRSPEC
))
52 if (mdb_vread(&mch
, sizeof (crypto_mechanism_t
), addr
) == -1) {
53 mdb_warn("cannot read %p", addr
);
56 /* XXX a future RFE will interpret cm_type */
57 mdb_printf("cm_type\t%ll#x\n", mch
.cm_type
);
58 mdb_printf("cm_param\t%p\n", mch
.cm_param
);
59 mdb_printf("cm_param_len\t%u\n", mch
.cm_param_len
);
65 iovec_prt(iovec_t
*addr
)
67 mdb_printf("iov_base\t%p\n", addr
->iov_base
);
68 mdb_printf("iov_len\t\t%d\n", addr
->iov_len
);
75 char *segstrings
[] = {
84 mdb_printf("uio\t%p\n", addr
);
85 if (mdb_vread(&uio
, sizeof (uio_t
), (uintptr_t)addr
)
87 mdb_warn("uio_prt: could not read uio");
90 for (i
= 0; i
< uio
.uio_iovcnt
; i
++) {
91 if (mdb_vread(&iov
, sizeof (iovec_t
),
92 (uintptr_t)(uio
.uio_iov
+i
))
94 mdb_printf("uio_iov\t?????");
95 mdb_warn("uio_prt: could not read uio_iov[%s]", i
);
100 mdb_printf("uio_iovcnt\t%d\n", uio
.uio_iovcnt
);
101 mdb_printf("uio_offset\t%lld\n", uio
.uio_offset
);
102 mdb_printf("uio_segflg\t%s", segstrings
[uio
.uio_segflg
]);
103 mdb_printf("uio_fmode\t0%o", (int)uio
.uio_fmode
);
104 mdb_printf("uio_limit\t%lld", uio
.uio_limit
);
105 mdb_printf("uio_resid\t%ld", uio
.uio_resid
);
108 static char *cdstrings
[] = {
116 * Routine to print either of two structrually identical sub-structures --
117 * with different naming conventions. Might be changed if we decide
118 * to merge the two. They are the cdu union from crypto_data_t and
119 * the one from crypto_dual_data_t.
122 typedef union crypto_data_union
{
123 iovec_t cdu_raw
; /* Raw format */
124 uio_t
*cdu_uio
; /* uio scatter-gather format */
125 mblk_t
*cdu_mp
; /* The mblk chain */
126 } crypto_data_union_t
;
130 prt_cdu(crypto_data_union_t
*cdu
, int format
, const char *prefix
)
134 case CRYPTO_DATA_RAW
:
135 mdb_printf("%s_raw:\n", prefix
);
137 iovec_prt(&cdu
->cdu_raw
);
141 case CRYPTO_DATA_UIO
:
142 mdb_printf("%s_uio:\n", prefix
);
144 uio_prt(cdu
->cdu_uio
);
148 case CRYPTO_DATA_MBLK
:
149 mdb_printf("%s_mp:\t\t%p\n", prefix
, cdu
->cdu_mp
);
153 mdb_printf("cm_format\t??????\n");
160 crypto_data(uintptr_t addr
, uint_t flags
, int argc
, const mdb_arg_t
*argv
)
164 if (!(flags
& DCMD_ADDRSPEC
))
167 if (mdb_vread(&data
, sizeof (crypto_data_t
), addr
) == -1) {
168 mdb_warn("cannot read %p", addr
);
171 if ((data
.cd_format
>= CRYPTO_DATA_RAW
) &&
172 (data
.cd_format
<= CRYPTO_DATA_MBLK
))
173 mdb_printf("cm_format\t%s\n", cdstrings
[data
.cd_format
]);
175 mdb_printf("bad cm_format\t%d\n", data
.cd_format
);
176 mdb_printf("cm_offset\t%ld\n", data
.cd_offset
);
177 mdb_printf("cm_length\t%ld\n", data
.cd_length
);
178 mdb_printf("cm_miscdata\t%p\n", data
.cd_miscdata
);
180 prt_cdu((crypto_data_union_t
*)&data
.cdu
, data
.cd_format
, "cdu");
187 crypto_dual_data(uintptr_t addr
, uint_t flags
, int argc
, const mdb_arg_t
*argv
)
189 crypto_dual_data_t ddata
;
191 if (!(flags
& DCMD_ADDRSPEC
))
194 if (mdb_vread(&ddata
, sizeof (crypto_dual_data_t
), addr
) == -1) {
195 mdb_warn("cannot read %p", addr
);
198 if ((ddata
.dd_format
> CRYPTO_DATA_RAW
) &&
199 (ddata
.dd_format
<= CRYPTO_DATA_MBLK
))
200 mdb_printf("dd_format\t%s\n", cdstrings
[ddata
.dd_format
]);
202 mdb_printf("bad dd_format\t%d\n", ddata
.dd_format
);
203 mdb_printf("dd_offset1\t%ld\n", ddata
.dd_offset1
);
204 mdb_printf("dd_len1\t%ld\n", ddata
.dd_len1
);
205 mdb_printf("dd_offset2\t%ld\n", ddata
.dd_offset2
);
206 mdb_printf("dd_len2\t%ld\n", ddata
.dd_len2
);
207 mdb_printf("dd_miscdata\t%p\n", ddata
.dd_miscdata
);
208 mdb_printf("cdu:\n");
210 prt_cdu((crypto_data_union_t
*)&ddata
.dd_data
.cdu
, ddata
.dd_format
,
219 crypto_key(uintptr_t addr
, uint_t flags
, int argc
, const mdb_arg_t
*argv
)
223 if (!(flags
& DCMD_ADDRSPEC
))
226 if (mdb_vread(&key
, sizeof (crypto_key_t
), addr
) == -1) {
227 mdb_warn("cannot read %p", addr
);
230 switch (key
.ck_format
) {
232 mdb_printf("ck_format:\tCRYPTO_KEY_RAW\n");
234 "cku_data.cku_key_value.cku_data.cku_v_length:\t%d\n",
235 key
.cku_data
.cku_key_value
.cku_v_length
);
236 mdb_printf("cku_data.cku_key_value.cku_v_data:\t%p\n",
237 key
.cku_data
.cku_key_value
.cku_v_data
);
239 case CRYPTO_KEY_REFERENCE
:
240 mdb_printf("ck_format:\tCRYPTO_KEY_REFERENCE\n");
241 mdb_printf("cku_data.cku_key_id:\t%u\n",
242 key
.cku_data
.cku_key_id
);
244 case CRYPTO_KEY_ATTR_LIST
:
245 mdb_printf("ck_format:\tCRYPTO_KEY_ATTR_LIST\n");
246 mdb_printf("cku_data.cku_key_attrs.cku_a_count:\t%u\n",
247 key
.cku_data
.cku_key_attrs
.cku_a_count
);
248 mdb_printf("cku_data.cku_key_attrs.cku_o_oattr:\t%p\n",
249 key
.cku_data
.cku_key_attrs
.cku_a_oattr
);
252 mdb_printf("ck_format:\t\t?????\n");