Yes, you can do such things with OpenStreetMap.
OpenStreetMap offers various data downloads ranging from the whole Planet down to Country and area extracts and even small cities or self-chosen areas.
If you want to calculate routes from OSM data you have to learn about elements, tags, the OSM XML format and many more things described in the OSM wiki. There you can also find a page about routing listing several already existing routing libraries as well as online routers and offline routers. Many of them are open source and they might be helpful if you get stuck at some point.