From d6fa02add60c1d9ef6c7c576de3beb0a5debfade Mon Sep 17 00:00:00 2001 From: Werner Koch Date: Mon, 9 Feb 1998 17:43:42 +0000 Subject: release 0.2.3 --- g10/comment.c | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) (limited to 'g10/comment.c') diff --git a/g10/comment.c b/g10/comment.c index 00bbac7dd..ce2e6cc4c 100644 --- a/g10/comment.c +++ b/g10/comment.c @@ -69,3 +69,30 @@ make_comment_node( const char *s ) } +KBNODE +make_mpi_comment_node( const char *s, MPI a ) +{ + PACKET *pkt; + byte *buf, *p, *pp; + unsigned n1, nb1; + size_t n = strlen(s); + + nb1 = mpi_get_nbits( a ); + p = buf = mpi_get_buffer( a, &n1, NULL ); + for( ; !*p && n1; p++, n1-- ) /* skip leading null bytes */ + ; + + pkt = m_alloc_clear( sizeof *pkt ); + pkt->pkttype = PKT_COMMENT; + pkt->pkt.comment = m_alloc( sizeof *pkt->pkt.comment + n + 2 + n1 ); + pkt->pkt.comment->len = n+1+2+n1; + pp = pkt->pkt.comment->data; + memcpy(pp, s, n+1); + pp[n+1] = nb1 >> 8; + pp[n+2] = nb1 ; + memcpy(pp+n+3, p, n1 ); + m_free(buf); + return new_kbnode( pkt ); +} + + -- cgit v1.2.3