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 include/sys/crypto/common.h
33 #include <sys/mdb_modapi.h>
34 #include <sys/modctl.h>
35 #include <sys/types.h>
36 #include <sys/crypto/api.h>
37 #include <sys/crypto/common.h>
38 #include <sys/crypto/spi.h>
39 #include <sys/crypto/impl.h>
40 #include "crypto_cmds.h"
44 crypto_mechanism(uintptr_t addr
, uint_t flags
, int argc
, const mdb_arg_t
*argv
)
46 crypto_mechanism_t mch
;
48 if (!(flags
& DCMD_ADDRSPEC
))
51 if (mdb_vread(&mch
, sizeof (crypto_mechanism_t
), addr
) == -1) {
52 mdb_warn("cannot read %p", addr
);
55 /* XXX a future RFE will interpret cm_type */
56 mdb_printf("cm_type\t%ll#x\n", mch
.cm_type
);
57 mdb_printf("cm_param\t%p\n", mch
.cm_param
);
58 mdb_printf("cm_param_len\t%u\n", mch
.cm_param_len
);
64 iovec_prt(iovec_t
*addr
)
66 mdb_printf("iov_base\t%p\n", addr
->iov_base
);
67 mdb_printf("iov_len\t\t%d\n", addr
->iov_len
);
74 char *segstrings
[] = {
83 mdb_printf("uio\t%p\n", addr
);
84 if (mdb_vread(&uio
, sizeof (uio_t
), (uintptr_t)addr
)
86 mdb_warn("uio_prt: could not read uio");
89 for (i
= 0; i
< uio
.uio_iovcnt
; i
++) {
90 if (mdb_vread(&iov
, sizeof (iovec_t
),
91 (uintptr_t)(uio
.uio_iov
+i
))
93 mdb_printf("uio_iov\t?????");
94 mdb_warn("uio_prt: could not read uio_iov[%s]", i
);
99 mdb_printf("uio_iovcnt\t%d\n", uio
.uio_iovcnt
);
100 mdb_printf("uio_offset\t%lld\n", uio
.uio_offset
);
101 mdb_printf("uio_segflg\t%s", segstrings
[uio
.uio_segflg
]);
102 mdb_printf("uio_fmode\t0%o", (int)uio
.uio_fmode
);
103 mdb_printf("uio_limit\t%lld", uio
.uio_limit
);
104 mdb_printf("uio_resid\t%ld", uio
.uio_resid
);
107 static char *cdstrings
[] = {
115 * Routine to print either of two structrually identical sub-structures --
116 * with different naming conventions. Might be changed if we decide
117 * to merge the two. They are the cdu union from crypto_data_t and
118 * the one from crypto_dual_data_t.
121 typedef union crypto_data_union
{
122 iovec_t cdu_raw
; /* Raw format */
123 uio_t
*cdu_uio
; /* uio scatter-gather format */
124 mblk_t
*cdu_mp
; /* The mblk chain */
125 } crypto_data_union_t
;
129 prt_cdu(crypto_data_union_t
*cdu
, int format
, const char *prefix
)
133 case CRYPTO_DATA_RAW
:
134 mdb_printf("%s_raw:\n", prefix
);
136 iovec_prt(&cdu
->cdu_raw
);
140 case CRYPTO_DATA_UIO
:
141 mdb_printf("%s_uio:\n", prefix
);
143 uio_prt(cdu
->cdu_uio
);
147 case CRYPTO_DATA_MBLK
:
148 mdb_printf("%s_mp:\t\t%p\n", prefix
, cdu
->cdu_mp
);
152 mdb_printf("cm_format\t??????\n");
159 crypto_data(uintptr_t addr
, uint_t flags
, int argc
, const mdb_arg_t
*argv
)
163 if (!(flags
& DCMD_ADDRSPEC
))
166 if (mdb_vread(&data
, sizeof (crypto_data_t
), addr
) == -1) {
167 mdb_warn("cannot read %p", addr
);
170 if ((data
.cd_format
>= CRYPTO_DATA_RAW
) &&
171 (data
.cd_format
<= CRYPTO_DATA_MBLK
))
172 mdb_printf("cm_format\t%s\n", cdstrings
[data
.cd_format
]);
174 mdb_printf("bad cm_format\t%d\n", data
.cd_format
);
175 mdb_printf("cm_offset\t%ld\n", data
.cd_offset
);
176 mdb_printf("cm_length\t%ld\n", data
.cd_length
);
177 mdb_printf("cm_miscdata\t%p\n", data
.cd_miscdata
);
179 prt_cdu((crypto_data_union_t
*)&data
.cdu
, data
.cd_format
, "cdu");
186 crypto_dual_data(uintptr_t addr
, uint_t flags
, int argc
, const mdb_arg_t
*argv
)
188 crypto_dual_data_t ddata
;
190 if (!(flags
& DCMD_ADDRSPEC
))
193 if (mdb_vread(&ddata
, sizeof (crypto_dual_data_t
), addr
) == -1) {
194 mdb_warn("cannot read %p", addr
);
197 if ((ddata
.dd_format
> CRYPTO_DATA_RAW
) &&
198 (ddata
.dd_format
<= CRYPTO_DATA_MBLK
))
199 mdb_printf("dd_format\t%s\n", cdstrings
[ddata
.dd_format
]);
201 mdb_printf("bad dd_format\t%d\n", ddata
.dd_format
);
202 mdb_printf("dd_offset1\t%ld\n", ddata
.dd_offset1
);
203 mdb_printf("dd_len1\t%ld\n", ddata
.dd_len1
);
204 mdb_printf("dd_offset2\t%ld\n", ddata
.dd_offset2
);
205 mdb_printf("dd_len2\t%ld\n", ddata
.dd_len2
);
206 mdb_printf("dd_miscdata\t%p\n", ddata
.dd_miscdata
);
207 mdb_printf("cdu:\n");
209 prt_cdu((crypto_data_union_t
*)&ddata
.dd_data
.cdu
, ddata
.dd_format
,
218 crypto_key(uintptr_t addr
, uint_t flags
, int argc
, const mdb_arg_t
*argv
)
222 if (!(flags
& DCMD_ADDRSPEC
))
225 if (mdb_vread(&key
, sizeof (crypto_key_t
), addr
) == -1) {
226 mdb_warn("cannot read %p", addr
);
229 switch (key
.ck_format
) {
231 mdb_printf("ck_format:\tCRYPTO_KEY_RAW\n");
233 "cku_data.cku_key_value.cku_data.cku_v_length:\t%d\n",
234 key
.cku_data
.cku_key_value
.cku_v_length
);
235 mdb_printf("cku_data.cku_key_value.cku_v_data:\t%p\n",
236 key
.cku_data
.cku_key_value
.cku_v_data
);
238 case CRYPTO_KEY_REFERENCE
:
239 mdb_printf("ck_format:\tCRYPTO_KEY_REFERENCE\n");
240 mdb_printf("cku_data.cku_key_id:\t%u\n",
241 key
.cku_data
.cku_key_id
);
243 case CRYPTO_KEY_ATTR_LIST
:
244 mdb_printf("ck_format:\tCRYPTO_KEY_ATTR_LIST\n");
245 mdb_printf("cku_data.cku_key_attrs.cku_a_count:\t%u\n",
246 key
.cku_data
.cku_key_attrs
.cku_a_count
);
247 mdb_printf("cku_data.cku_key_attrs.cku_o_oattr:\t%p\n",
248 key
.cku_data
.cku_key_attrs
.cku_a_oattr
);
251 mdb_printf("ck_format:\t\t?????\n");