[vlc-devel] [PATCH] dcp: read encrypted DCPs
Jean-Baptiste Kempf
jb at videolan.org
Tue Apr 29 16:40:57 CEST 2014
On 29 Apr, Simona-Marinela Prodea wrote :
> +static bool isBlank( char c )
> +{
> + return ( c == '\n' || c == '\r' || c == '\t' || c == ' ' );
> +};
Doesn't this already exist somewhere?
> + free( ps_cipher_text );
> + gcry_mpi_release( cipher_text_mpi );
> + gcry_sexp_release( cipher_text_sexp );
> + gcry_sexp_release( plain_text_sexp );
> + gcry_mpi_release( plain_text_mpi );
> + gcry_sexp_release( tmp_sexp );
> + gcry_free( ps_plain_text );
> + return VLC_SUCCESS;
> +
> +error:
> + free( ps_cipher_text );
> + gcry_mpi_release( cipher_text_mpi );
> + gcry_sexp_release( cipher_text_sexp );
> + gcry_sexp_release( plain_text_sexp );
> + gcry_mpi_release( plain_text_mpi );
> + gcry_sexp_release( tmp_sexp );
> + gcry_free( ps_plain_text );
> + return VLC_EGENERIC;
> +}
You are doing that too often. Use i_ret and return i_ret, but there is
too much copy paste.
> diff --git a/modules/access/dcp/dcpdecrypt.h b/modules/access/dcp/dcpdecrypt.h
I'm not sure you need a new .hpp.
> +class KDM : public XmlFile {
> +
> +public:
> + KDM( demux_t * p_demux, string s_path, dcp_t *_p_dcp )
> + : XmlFile( p_demux, s_path ), p_dcp(_p_dcp) {}
> + ~KDM() {};
Useless destructor.
> + virtual int Parse();
> +
> +private:
> + dcp_t *p_dcp;
> +
> + int ParsePrivate( const string s_node, int i_type );
> +};
> +class AESKey
> +{
> +public:
> + AESKey( demux_t *demux ): p_demux( demux ) { }
> + ~AESKey() {};
I'd prefer having a virtual here.
> + const string getKeyId() { return this->s_key_id; };
> + const unsigned char * getKey() { return this->ps_key; };
> +
> + int Parse( xml_reader_t *p_xml_reader, string s_node, int i_type );
> +
> +private:
> + demux_t *p_demux;
> + string s_key_id;
> + unsigned char ps_key[16];
> +
> + int decryptRSA( string s_cipher_text_b64 );
> + int extractInfo( unsigned char * ps_plain_text, bool smpte );
> +};
> +
> +class RSAKey
> +{
> +public:
> + RSAKey( demux_t *demux ):
> + priv_key( NULL ), p_demux( demux ) { }
> + ~RSAKey() { gcry_sexp_release( priv_key ); }
idem.
> + /* some ASN.1 tags. */
> + enum
> + {
> + TAG_INTEGER = 2,
> + TAG_SEQUENCE = 16,
> + };
> +
> + /* ASN.1 Parser object. */
> + struct tag_info
> + {
> + int class_; /* Object class. */
> + unsigned long tag; /* The tag of the object. */
> + unsigned long length; /* Length of the values. */
> + int nhdr; /* Length of the header (TL). */
> + unsigned int ndef:1; /* The object has an indefinite length. */
> + unsigned int cons:1; /* This is a constructed object. */
> + };
> +
> + int setPath();
> + int readPEM();
> + int readDER( unsigned char const *ps_data_der, size_t length );
> + int parseTag( unsigned char const **buffer, size_t *buflen, struct tag_info *ti);
> +
> + gcry_sexp_t priv_key;
> +
> +private:
> + demux_t *p_demux;
> + string s_path;
> +};
With my kindest regards,
--
Jean-Baptiste Kempf
http://www.jbkempf.com/ - +33 672 704 734
Sent from my Electronic Device
More information about the vlc-devel
mailing list