/** * cdk_stream_set_hash_flag: * @s: the stream object * @digest_algo: the digest algorithm to use * * This is for read-only streams. It pushes a digest filter to * calculate the digest of the given stream data. **/ cdk_error_t cdk_stream_set_hash_flag (cdk_stream_t s, int digest_algo) { struct stream_filter_s *f; if (!s) { gnutls_assert (); return CDK_Inv_Value; } if (stream_get_mode (s)) { gnutls_assert (); return CDK_Inv_Mode; } f = filter_add (s, _cdk_filter_hash, fHASH); if (!f) { gnutls_assert (); return CDK_Out_Of_Core; } f->ctl = stream_get_mode (s); f->u.mfx.digest_algo = digest_algo; f->flags.rdonly = 1; return 0; }
/** * cdk_stream_set_literal_flag: * @s: the stream object * @mode: the mode to use (binary, text, unicode) * @fname: the file name to store in the packet. * * In read mode it kicks off the literal decoding routine to * unwrap the data from the packet. The @mode parameter is ignored. * In write mode the function can be used to wrap the stream data * into a literal packet with the given mode and file name. **/ cdk_error_t cdk_stream_set_literal_flag (cdk_stream_t s, cdk_lit_format_t mode, const char *fname) { struct stream_filter_s *f; const char *orig_fname; _cdk_log_debug ("stream: enable literal mode.\n"); if (!s) { gnutls_assert (); return CDK_Inv_Value; } orig_fname = _cdk_stream_get_fname (s); f = filter_add (s, _cdk_filter_literal, fLITERAL); if (!f) { gnutls_assert (); return CDK_Out_Of_Core; } f->u.pfx.mode = mode; f->u.pfx.filename = fname ? cdk_strdup (fname) : NULL; f->u.pfx.orig_filename = orig_fname ? cdk_strdup (orig_fname) : NULL; f->ctl = stream_get_mode (s); if (s->blkmode > 0) { f->u.pfx.blkmode.on = 1; f->u.pfx.blkmode.size = s->blkmode; } return 0; }
cdk_error_t cdk_stream_set_text_flag( cdk_stream_t s, const char * lf ) { struct stream_filter_s * f; if( !s ) return CDK_Inv_Value; f = filter_add( s, _cdk_filter_text, fTEXT ); if( !f ) return CDK_Out_Of_Core; f->ctl = stream_get_mode( s ); f->u.tfx.lf = lf; return 0; }
cdk_error_t cdk_stream_set_armor_flag( cdk_stream_t s, int type ) { struct stream_filter_s * f; if( !s ) return CDK_Inv_Value; f = filter_add( s, _cdk_filter_armor, fARMOR ); if( !f ) return CDK_Out_Of_Core; f->u.afx.idx = f->u.afx.idx2 = type; f->ctl = stream_get_mode( s ); return 0; }
cdk_error_t cdk_stream_set_compress_flag( cdk_stream_t s, int algo, int level ) { struct stream_filter_s * f; if( !s ) return CDK_Inv_Value; f = filter_add( s, _cdk_filter_compress, fCOMPRESS ); if( !f ) return CDK_Out_Of_Core; f->ctl = stream_get_mode( s ); f->u.zfx.algo = algo; f->u.zfx.level = level; return 0; }
cdk_error_t cdk_stream_set_literal_flag( cdk_stream_t s, int mode, const char * fname ) { struct stream_filter_s * f; if( !s ) return CDK_Inv_Value; f = filter_add( s, _cdk_filter_literal, fLITERAL ); if( !f ) return CDK_Out_Of_Core; f->u.pfx.mode = mode; f->u.pfx.filename = fname? cdk_strdup( fname ) : NULL; f->ctl = stream_get_mode( s ); if( s->blkmode ) { f->u.pfx.blkmode.on = 1; f->u.pfx.blkmode.size = s->blkmode; } return 0; }
cdk_error_t cdk_stream_set_cipher_flag( cdk_stream_t s, cdk_dek_t dek, int use_mdc ) { struct stream_filter_s * f; if( !s ) return CDK_Inv_Value; f = filter_add( s, _cdk_filter_cipher, fCIPHER ); if( !f ) return CDK_Out_Of_Core; dek->use_mdc = use_mdc; f->ctl = stream_get_mode( s ); f->u.cfx.dek = dek; f->u.cfx.mdc_method = use_mdc? GCRY_MD_SHA1 : 0; if( s->blkmode ) { f->u.cfx.blkmode.on = 1; f->u.cfx.blkmode.size = s->blkmode; } return 0; }
/** * cdk_stream_set_compress_flag: * @s: the stream object * @algo: the compression algo * @level: level of compression (0..9) * * In read mode it kicks off the decompression filter to retrieve * the uncompressed data. * In write mode the stream data will be compressed with the * given algorithm at the given level. **/ cdk_error_t cdk_stream_set_compress_flag (cdk_stream_t s, int algo, int level) { gnutls_assert (); return CDK_Not_Implemented; #if 0 struct stream_filter_s *f; if (!s) return CDK_Inv_Value; f = filter_add (s, _cdk_filter_compress, fCOMPRESS); if (!f) return CDK_Out_Of_Core; f->ctl = stream_get_mode (s); f->u.zfx.algo = algo; f->u.zfx.level = level; return 0; #endif }