Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8120057
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T05:00:07+00:00 2026-06-06T05:00:07+00:00

My goal is to read the data stored in a bio (assuming that it

  • 0

My goal is to read the data stored in a bio (assuming that it is for a write operation) and compute its md5 fingerprint. The data could be anything. I made several attempts. Here is my latest attempt:

void fingerprint(struct bio * bio, unsigned char * result)
{
char * place;
char * cpy;
int total;
struct buffer_head * bh;
struct scatterlist sg;
struct hash_desc desc = {
    .tfm = crypto_alloc_hash("md5", 0, CRYPTO_ALG_ASYNC),
    .flags = CRYPTO_TFM_REQ_MAY_SLEEP
};
total = 0;

cpy = kmalloc(sizeof(char) * bio->bi_io_vec[i].bv_len, GFP_KERNEL);
bh = (struct buffer_head *)bio->bi_io_vec[i].bv_page->private;
    place = bh->b_data + bio->bi_io_vec[i].bv_offset;

DPRINTK("%u", bio->bi_io_vec[i].bv_offset);
DPRINTK("%u", place);

memcpy(cpy, place, bio->bi_io_vec[i].bv_len);
DPRINTK("%x", place);
DPRINTK("%x", cpy);

sg_init_one(&sg, (u8 *)cpy, bio->bi_io_vec[i].bv_len);
crypto_hash_init(&desc);
crypto_hash_update(&desc, &sg, bio->bi_io_vec[i].bv_len);
total += bio->bi_io_vec[i].bv_len;
DPRINTK("%u", bio->bi_vcnt);
DPRINTK("%u", total);

crypto_hash_final(&desc, result);
kfree(cpy);
}

The results of the hash are very similar if not exactly the same and they are always even numbers. I print out the results as long long’s and in hex. Why is this happening?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-06T05:00:09+00:00Added an answer on June 6, 2026 at 5:00 am

    You need to test your code. Cut down your code to the MD5 minimum, and try a few test vectors.

    “” -> d41d8cd98f00b204e9800998ecf8427e

    “The quick brown fox jumps over the lazy dog” -> 9e107d9d372bb6826bd81d3542a419d6

    “The quick brown fox jumps over the lazy dog.” -> e4d909c290d0fb1ca068ffaddf22cbd0

    (Note the extra full stop in the third example.)

    Once you are sure MD5 is working correctly, then gradually reintroduce the other parts of your code and recheck regularly.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

If I have 1. mainThread: write data A, 2. Thread_1: read A and write
The goal is to have a singleton data controller class called FetchData.h/.m that pulls
Goal: Website1 sends Website2 user data through http requests. Problem: Website2 is ensured that
For my data structures project, the goal is to read in a provided file
I have a database table, my goal is to read in each of the
My goal is to provide something like a Read More link next to a
The goal of the following code sample is to read the contents of $target
Goal is to make a dialog that appears on menu_key pressed, but it keeps
Goal: Produce an Excel document with information from 3 associated models that is similar
I have been working on a Core Data iOS app that works perfectly through

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.