Lines Matching refs:ctx
71 struct trad_pkware *ctx; in zip_source_pkware() local
86 if ((ctx=(struct trad_pkware *)malloc(sizeof(*ctx))) == NULL) { in zip_source_pkware()
91 ctx->e[0] = ctx->e[1] = 0; in zip_source_pkware()
93 ctx->key[0] = KEY0; in zip_source_pkware()
94 ctx->key[1] = KEY1; in zip_source_pkware()
95 ctx->key[2] = KEY2; in zip_source_pkware()
96 decrypt(ctx, NULL, (const zip_uint8_t *)password, strlen(password), 1); in zip_source_pkware()
98 if ((s2=zip_source_layered(za, src, pkware_decrypt, ctx)) == NULL) { in zip_source_pkware()
99 pkware_free(ctx); in zip_source_pkware()
109 decrypt(struct trad_pkware *ctx, zip_uint8_t *out, const zip_uint8_t *in, in decrypt() argument
121 tmp = ctx->key[2] | 2; in decrypt()
131 ctx->key[0] = CRC32(ctx->key[0], b); in decrypt()
132 ctx->key[1] = (ctx->key[1] + (ctx->key[0] & 0xff)) * 134775813 + 1; in decrypt()
133 b = ctx->key[1] >> 24; in decrypt()
134 ctx->key[2] = CRC32(ctx->key[2], b); in decrypt()
141 decrypt_header(struct zip_source *src, struct trad_pkware *ctx) in decrypt_header() argument
149 zip_source_error(src, ctx->e, ctx->e+1); in decrypt_header()
154 ctx->e[0] = ZIP_ER_EOF; in decrypt_header()
155 ctx->e[1] = 0; in decrypt_header()
159 decrypt(ctx, header, header, HEADERLEN, 0); in decrypt_header()
170 ctx->e[0] = ZIP_ER_WRONGPASSWD; in decrypt_header()
171 ctx->e[1] = 0; in decrypt_header()
184 struct trad_pkware *ctx; in pkware_decrypt() local
187 ctx = (struct trad_pkware *)ud; in pkware_decrypt()
191 if (decrypt_header(src, ctx) < 0) in pkware_decrypt()
221 memcpy(data, ctx->e, sizeof(int)*2); in pkware_decrypt()
225 pkware_free(ctx); in pkware_decrypt()
229 ctx->e[0] = ZIP_ER_INVAL; in pkware_decrypt()
230 ctx->e[1] = 0; in pkware_decrypt()
238 pkware_free(struct trad_pkware *ctx) in pkware_free() argument
240 free(ctx); in pkware_free()